@difizen/libro-core 0.1.1 → 0.1.2

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 (302) hide show
  1. package/es/add-cell/index.less +1 -1
  2. package/es/add-cell/libro-add-cell-slot-contribution.d.ts +1 -2
  3. package/es/add-cell/libro-add-cell-slot-contribution.d.ts.map +1 -1
  4. package/es/add-cell/libro-add-cell-slot-contribution.js +12 -6
  5. package/es/add-cell/libro-add-cell-view.d.ts +4 -4
  6. package/es/add-cell/libro-add-cell-view.d.ts.map +1 -1
  7. package/es/add-cell/libro-add-cell-view.js +4 -6
  8. package/es/cell/libro-cell-contribution.d.ts +1 -2
  9. package/es/cell/libro-cell-contribution.d.ts.map +1 -1
  10. package/es/cell/libro-cell-contribution.js +14 -8
  11. package/es/cell/libro-cell-model.d.ts +9 -0
  12. package/es/cell/libro-cell-model.d.ts.map +1 -1
  13. package/es/cell/libro-cell-model.js +53 -11
  14. package/es/cell/libro-cell-protocol.d.ts +2 -0
  15. package/es/cell/libro-cell-protocol.d.ts.map +1 -1
  16. package/es/cell/libro-cell-view.d.ts +6 -2
  17. package/es/cell/libro-cell-view.d.ts.map +1 -1
  18. package/es/cell/libro-cell-view.js +54 -24
  19. package/es/cell/libro-edit-cell-view.d.ts +6 -12
  20. package/es/cell/libro-edit-cell-view.d.ts.map +1 -1
  21. package/es/cell/libro-edit-cell-view.js +9 -4
  22. package/es/cell/libro-executable-cell-view.d.ts +2 -0
  23. package/es/cell/libro-executable-cell-view.d.ts.map +1 -1
  24. package/es/cell/libro-executable-cell-view.js +4 -1
  25. package/es/collapse-service.d.ts +1 -1
  26. package/es/collapse-service.d.ts.map +1 -1
  27. package/es/collapse-service.js +1 -1
  28. package/es/command/document-commands.d.ts +1 -2
  29. package/es/command/document-commands.d.ts.map +1 -1
  30. package/es/command/document-commands.js +3 -2
  31. package/es/command/kernel-command.d.ts.map +1 -1
  32. package/es/command/kernel-command.js +3 -0
  33. package/es/command/libro-command-contribution.d.ts +0 -1
  34. package/es/command/libro-command-contribution.d.ts.map +1 -1
  35. package/es/command/libro-command-contribution.js +179 -129
  36. package/es/command/libro-command-register.d.ts +0 -1
  37. package/es/command/libro-command-register.d.ts.map +1 -1
  38. package/es/command/libro-command-register.js +13 -7
  39. package/es/command/notebook-commands.d.ts.map +1 -1
  40. package/es/command/notebook-commands.js +17 -4
  41. package/es/components/cell-protocol.d.ts +5 -5
  42. package/es/components/cell-protocol.d.ts.map +1 -1
  43. package/es/components/dnd-cell-item-render.d.ts +6 -2
  44. package/es/components/dnd-cell-item-render.d.ts.map +1 -1
  45. package/es/components/dnd-cell-item-render.js +194 -89
  46. package/es/components/dnd-component/custom-drag-layer.d.ts +1 -1
  47. package/es/components/dnd-component/custom-drag-layer.d.ts.map +1 -1
  48. package/es/components/dnd-component/custom-drag-layer.js +3 -4
  49. package/es/components/dnd-component/default-dnd-content.d.ts +2 -1
  50. package/es/components/dnd-component/default-dnd-content.d.ts.map +1 -1
  51. package/es/components/dnd-component/default-dnd-content.js +100 -44
  52. package/es/components/dnd-component/dnd-context.js +1 -1
  53. package/es/components/dnd-component/dnd-list.d.ts +9 -5
  54. package/es/components/dnd-component/dnd-list.d.ts.map +1 -1
  55. package/es/components/dnd-component/dnd-list.js +93 -26
  56. package/es/components/dnd-component/index.d.ts +1 -1
  57. package/es/components/dnd-component/index.d.ts.map +1 -1
  58. package/es/components/dnd-component/index.js +2 -2
  59. package/es/components/dnd-component/index.less +8 -0
  60. package/es/components/dnd-component/overscanIndices-getter.d.ts +22 -0
  61. package/es/components/dnd-component/overscanIndices-getter.d.ts.map +1 -0
  62. package/es/components/dnd-component/overscanIndices-getter.js +58 -0
  63. package/es/components/dnd-component/virtualized-manager.d.ts +19 -0
  64. package/es/components/dnd-component/virtualized-manager.d.ts.map +1 -0
  65. package/es/components/dnd-component/virtualized-manager.js +60 -0
  66. package/es/components/index.d.ts +2 -2
  67. package/es/components/index.d.ts.map +1 -1
  68. package/es/components/index.js +2 -2
  69. package/es/components/libro-virtualized-render.d.ts +15 -0
  70. package/es/components/libro-virtualized-render.d.ts.map +1 -0
  71. package/es/components/libro-virtualized-render.js +174 -0
  72. package/es/content/index.d.ts +1 -0
  73. package/es/content/index.d.ts.map +1 -1
  74. package/es/content/index.js +2 -1
  75. package/es/content/libro-content-contribution.d.ts +2 -2
  76. package/es/content/libro-content-contribution.d.ts.map +1 -1
  77. package/es/content/libro-content-contribution.js +2 -3
  78. package/es/content/libro-content-module.d.ts.map +1 -1
  79. package/es/content/libro-content-module.js +3 -2
  80. package/es/content/libro-content-protocol.d.ts +5 -0
  81. package/es/content/libro-content-protocol.d.ts.map +1 -1
  82. package/es/content/libro-content-protocol.js +2 -1
  83. package/es/content/libro-content-service.d.ts +5 -3
  84. package/es/content/libro-content-service.d.ts.map +1 -1
  85. package/es/content/libro-content-service.js +36 -8
  86. package/es/content/libro-save-content-contribution.d.ts +6 -0
  87. package/es/content/libro-save-content-contribution.d.ts.map +1 -0
  88. package/es/content/libro-save-content-contribution.js +27 -0
  89. package/es/formatter/index.d.ts +6 -0
  90. package/es/formatter/index.d.ts.map +1 -0
  91. package/es/formatter/index.js +5 -0
  92. package/es/formatter/libro-formatter-json-contribution.d.ts +18 -0
  93. package/es/formatter/libro-formatter-json-contribution.d.ts.map +1 -0
  94. package/es/formatter/libro-formatter-json-contribution.js +41 -0
  95. package/es/formatter/libro-formatter-manager.d.ts +16 -0
  96. package/es/formatter/libro-formatter-manager.d.ts.map +1 -0
  97. package/es/formatter/libro-formatter-manager.js +86 -0
  98. package/es/formatter/libro-formatter-module.d.ts +3 -0
  99. package/es/formatter/libro-formatter-module.d.ts.map +1 -0
  100. package/es/formatter/libro-formatter-module.js +7 -0
  101. package/es/formatter/libro-formatter-protocol.d.ts +37 -0
  102. package/es/formatter/libro-formatter-protocol.d.ts.map +1 -0
  103. package/es/formatter/libro-formatter-protocol.js +18 -0
  104. package/es/formatter/libro-formatter-string-contribution.d.ts +18 -0
  105. package/es/formatter/libro-formatter-string-contribution.d.ts.map +1 -0
  106. package/es/formatter/libro-formatter-string-contribution.js +41 -0
  107. package/es/formatter/libro-formatter-trans-default-contribution.d.ts +7 -0
  108. package/es/formatter/libro-formatter-trans-default-contribution.d.ts.map +1 -0
  109. package/es/formatter/libro-formatter-trans-default-contribution.js +19 -0
  110. package/es/index.d.ts +5 -1
  111. package/es/index.d.ts.map +1 -1
  112. package/es/index.js +6 -2
  113. package/es/index.less +135 -58
  114. package/es/libro-context-key.d.ts.map +1 -1
  115. package/es/libro-model.d.ts +13 -2
  116. package/es/libro-model.d.ts.map +1 -1
  117. package/es/libro-model.js +149 -70
  118. package/es/libro-protocol.d.ts +44 -2
  119. package/es/libro-protocol.d.ts.map +1 -1
  120. package/es/libro-protocol.js +16 -3
  121. package/es/libro-service.d.ts +1 -1
  122. package/es/libro-service.d.ts.map +1 -1
  123. package/es/libro-service.js +29 -20
  124. package/es/{configuration/libro-configuration-contribution.d.ts → libro-setting-contribution.d.ts} +2 -2
  125. package/es/libro-setting-contribution.d.ts.map +1 -0
  126. package/es/{configuration/libro-configuration-contribution.js → libro-setting-contribution.js} +8 -9
  127. package/es/{configuration/libro-configuration.d.ts → libro-setting.d.ts} +3 -2
  128. package/es/libro-setting.d.ts.map +1 -0
  129. package/es/{configuration/libro-configuration.js → libro-setting.js} +17 -7
  130. package/es/libro-view.d.ts +21 -8
  131. package/es/libro-view.d.ts.map +1 -1
  132. package/es/libro-view.js +477 -338
  133. package/es/material-from-designer.d.ts +3 -0
  134. package/es/material-from-designer.d.ts.map +1 -1
  135. package/es/material-from-designer.js +112 -1
  136. package/es/module.d.ts.map +1 -1
  137. package/es/module.js +20 -5
  138. package/es/output/output-area.d.ts +3 -4
  139. package/es/output/output-area.d.ts.map +1 -1
  140. package/es/output/output-area.js +23 -16
  141. package/es/output/output-contribution.d.ts +0 -1
  142. package/es/output/output-contribution.d.ts.map +1 -1
  143. package/es/output/output-contribution.js +14 -9
  144. package/es/output/output-model.d.ts +2 -2
  145. package/es/output/output-model.d.ts.map +1 -1
  146. package/es/output/output-model.js +2 -2
  147. package/es/output/output-protocol.d.ts.map +1 -1
  148. package/es/output/output-protocol.js +0 -2
  149. package/es/settings/index.d.ts +5 -0
  150. package/es/settings/index.d.ts.map +1 -0
  151. package/es/settings/index.js +4 -0
  152. package/es/settings/index.less +3 -0
  153. package/es/settings/module.d.ts +3 -0
  154. package/es/settings/module.d.ts.map +1 -0
  155. package/es/settings/module.js +4 -0
  156. package/es/settings/setting-editor/configuration-panel-view.d.ts +13 -0
  157. package/es/settings/setting-editor/configuration-panel-view.d.ts.map +1 -0
  158. package/es/settings/setting-editor/configuration-panel-view.js +115 -0
  159. package/es/settings/setting-editor/configuration-render-contribution.d.ts +6 -0
  160. package/es/settings/setting-editor/configuration-render-contribution.d.ts.map +1 -0
  161. package/es/settings/setting-editor/configuration-render-contribution.js +77 -0
  162. package/es/settings/setting-editor/default-node-render.d.ts +9 -0
  163. package/es/settings/setting-editor/default-node-render.d.ts.map +1 -0
  164. package/es/settings/setting-editor/default-node-render.js +79 -0
  165. package/es/settings/setting-editor/index.d.ts +7 -0
  166. package/es/settings/setting-editor/index.d.ts.map +1 -0
  167. package/es/settings/setting-editor/index.js +6 -0
  168. package/es/settings/setting-editor/index.less +12 -0
  169. package/es/settings/setting-editor/module.d.ts +3 -0
  170. package/es/settings/setting-editor/module.d.ts.map +1 -0
  171. package/es/settings/setting-editor/module.js +7 -0
  172. package/es/settings/setting-editor/setting-editor-view.d.ts +15 -0
  173. package/es/settings/setting-editor/setting-editor-view.d.ts.map +1 -0
  174. package/es/settings/setting-editor/setting-editor-view.js +169 -0
  175. package/es/settings/setting-editor/setting-tree-service.d.ts +9 -0
  176. package/es/settings/setting-editor/setting-tree-service.d.ts.map +1 -0
  177. package/es/settings/setting-editor/setting-tree-service.js +118 -0
  178. package/es/settings/setting-editor/setting-tree-view.d.ts +19 -0
  179. package/es/settings/setting-editor/setting-tree-view.d.ts.map +1 -0
  180. package/es/settings/setting-editor/setting-tree-view.js +88 -0
  181. package/es/settings/settings-contribution.d.ts +7 -0
  182. package/es/settings/settings-contribution.d.ts.map +1 -0
  183. package/es/settings/settings-contribution.js +36 -0
  184. package/es/settings/settings-modal.d.ts +5 -0
  185. package/es/settings/settings-modal.d.ts.map +1 -0
  186. package/es/settings/settings-modal.js +53 -0
  187. package/es/settings/settings-modal.less +3 -0
  188. package/es/settings/settings-protocol.d.ts +4 -0
  189. package/es/settings/settings-protocol.d.ts.map +1 -0
  190. package/es/settings/settings-protocol.js +5 -0
  191. package/es/slot/libro-slot-manager.d.ts +2 -2
  192. package/es/slot/libro-slot-manager.d.ts.map +1 -1
  193. package/es/slot/libro-slot-manager.js +14 -8
  194. package/es/slot/libro-slot-view.d.ts +3 -3
  195. package/es/slot/libro-slot-view.d.ts.map +1 -1
  196. package/es/slot/libro-slot-view.js +2 -2
  197. package/es/theme/libro-color-registry.d.ts.map +1 -1
  198. package/es/theme/libro-color-registry.js +7 -0
  199. package/es/toolbar/all-outputs-scroll-icon.d.ts +3 -0
  200. package/es/toolbar/all-outputs-scroll-icon.d.ts.map +1 -0
  201. package/es/toolbar/all-outputs-scroll-icon.js +10 -0
  202. package/es/toolbar/libro-toolbar.d.ts +2 -1
  203. package/es/toolbar/libro-toolbar.d.ts.map +1 -1
  204. package/es/toolbar/libro-toolbar.js +44 -8
  205. package/es/toolbar/restart-clear-outputs-modal.d.ts +1 -2
  206. package/es/toolbar/restart-clear-outputs-modal.d.ts.map +1 -1
  207. package/es/toolbar/restart-clear-outputs-modal.js +2 -2
  208. package/es/toolbar/shutdown-modal.d.ts +1 -2
  209. package/es/toolbar/shutdown-modal.d.ts.map +1 -1
  210. package/es/toolbar/shutdown-modal.js +2 -2
  211. package/es/toolbar/side-toolar-more-select.d.ts.map +1 -1
  212. package/es/toolbar/side-toolar-more-select.js +2 -2
  213. package/es/virtualized-manager-helper.d.ts +11 -0
  214. package/es/virtualized-manager-helper.d.ts.map +1 -0
  215. package/es/virtualized-manager-helper.js +51 -0
  216. package/es/virtualized-manager.d.ts +19 -0
  217. package/es/virtualized-manager.d.ts.map +1 -0
  218. package/es/virtualized-manager.js +61 -0
  219. package/package.json +9 -6
  220. package/src/add-cell/index.less +1 -1
  221. package/src/add-cell/libro-add-cell-slot-contribution.ts +1 -4
  222. package/src/add-cell/libro-add-cell-view.tsx +13 -6
  223. package/src/cell/libro-cell-contribution.ts +2 -6
  224. package/src/cell/libro-cell-model.ts +57 -4
  225. package/src/cell/libro-cell-protocol.ts +2 -0
  226. package/src/cell/libro-cell-view.tsx +21 -9
  227. package/src/cell/libro-edit-cell-view.tsx +10 -9
  228. package/src/cell/libro-executable-cell-view.ts +6 -1
  229. package/src/collapse-service.ts +1 -1
  230. package/src/command/document-commands.ts +3 -5
  231. package/src/command/kernel-command.ts +3 -0
  232. package/src/command/libro-command-contribution.ts +107 -91
  233. package/src/command/libro-command-register.ts +1 -4
  234. package/src/command/notebook-commands.ts +16 -3
  235. package/src/components/cell-protocol.ts +5 -5
  236. package/src/components/dnd-cell-item-render.tsx +239 -92
  237. package/src/components/dnd-component/custom-drag-layer.tsx +5 -6
  238. package/src/components/dnd-component/default-dnd-content.tsx +113 -42
  239. package/src/components/dnd-component/dnd-context.tsx +1 -1
  240. package/src/components/dnd-component/dnd-list.tsx +135 -43
  241. package/src/components/dnd-component/index.less +8 -0
  242. package/src/components/dnd-component/index.tsx +1 -1
  243. package/src/components/dnd-component/overscanIndices-getter.ts +92 -0
  244. package/src/components/dnd-component/virtualized-manager.ts +34 -0
  245. package/src/components/index.ts +2 -2
  246. package/src/components/libro-virtualized-render.tsx +178 -0
  247. package/src/content/index.ts +1 -0
  248. package/src/content/libro-content-contribution.ts +2 -3
  249. package/src/content/libro-content-module.ts +11 -3
  250. package/src/content/libro-content-protocol.ts +6 -0
  251. package/src/content/libro-content-service.ts +26 -8
  252. package/src/content/libro-save-content-contribution.ts +12 -0
  253. package/src/formatter/index.ts +5 -0
  254. package/src/formatter/libro-formatter-json-contribution.ts +42 -0
  255. package/src/formatter/libro-formatter-manager.ts +85 -0
  256. package/src/formatter/libro-formatter-module.ts +19 -0
  257. package/src/formatter/libro-formatter-protocol.ts +63 -0
  258. package/src/formatter/libro-formatter-string-contribution.ts +41 -0
  259. package/src/formatter/libro-formatter-trans-default-contribution.ts +15 -0
  260. package/src/index.less +135 -58
  261. package/src/index.tsx +6 -1
  262. package/src/libro-context-key.ts +3 -3
  263. package/src/libro-model.ts +87 -23
  264. package/src/libro-protocol.ts +81 -4
  265. package/src/libro-service.ts +4 -13
  266. package/src/{configuration/libro-configuration-contribution.ts → libro-setting-contribution.ts} +7 -8
  267. package/src/{configuration/libro-configuration.ts → libro-setting.ts} +18 -7
  268. package/src/libro-view.tsx +273 -141
  269. package/src/material-from-designer.tsx +93 -1
  270. package/src/module.ts +29 -7
  271. package/src/output/output-area.tsx +18 -12
  272. package/src/output/output-contribution.ts +2 -6
  273. package/src/output/output-model.tsx +3 -3
  274. package/src/output/output-protocol.ts +0 -1
  275. package/src/settings/index.less +3 -0
  276. package/src/settings/index.ts +4 -0
  277. package/src/settings/module.ts +8 -0
  278. package/src/settings/setting-editor/configuration-panel-view.tsx +89 -0
  279. package/src/settings/setting-editor/configuration-render-contribution.ts +81 -0
  280. package/src/settings/setting-editor/default-node-render.tsx +65 -0
  281. package/src/settings/setting-editor/index.less +12 -0
  282. package/src/settings/setting-editor/index.ts +6 -0
  283. package/src/settings/setting-editor/module.ts +17 -0
  284. package/src/settings/setting-editor/setting-editor-view.tsx +93 -0
  285. package/src/settings/setting-editor/setting-tree-service.ts +82 -0
  286. package/src/settings/setting-editor/setting-tree-view.tsx +95 -0
  287. package/src/settings/settings-contribution.tsx +24 -0
  288. package/src/settings/settings-modal.less +3 -0
  289. package/src/settings/settings-modal.tsx +50 -0
  290. package/src/settings/settings-protocol.ts +7 -0
  291. package/src/slot/libro-slot-manager.ts +1 -3
  292. package/src/slot/libro-slot-view.tsx +2 -5
  293. package/src/theme/libro-color-registry.ts +6 -0
  294. package/src/toolbar/all-outputs-scroll-icon.tsx +19 -0
  295. package/src/toolbar/libro-toolbar.tsx +30 -5
  296. package/src/toolbar/restart-clear-outputs-modal.tsx +3 -3
  297. package/src/toolbar/shutdown-modal.tsx +3 -3
  298. package/src/toolbar/side-toolar-more-select.tsx +2 -1
  299. package/src/virtualized-manager-helper.ts +29 -0
  300. package/src/virtualized-manager.ts +34 -0
  301. package/es/configuration/libro-configuration-contribution.d.ts.map +0 -1
  302. package/es/configuration/libro-configuration.d.ts.map +0 -1
@@ -0,0 +1,93 @@
1
+ import {
2
+ BaseView,
3
+ view,
4
+ singleton,
5
+ ViewRender,
6
+ inject,
7
+ ViewManager,
8
+ useInject,
9
+ ViewInstance,
10
+ prop,
11
+ URI,
12
+ ConfigurationRegistry,
13
+ } from '@difizen/mana-app';
14
+ import { SplitPanel } from '@difizen/mana-react';
15
+ import { useEffect, useState } from 'react';
16
+
17
+ import { ConfigurationPanelView } from './configuration-panel-view.js';
18
+ import { SettingTreeView } from './setting-tree-view.js';
19
+
20
+ export const SettingEditorComponent: React.FC = () => {
21
+ const viewInstance = useInject<SettingEditorView>(ViewInstance);
22
+ const viewManager = useInject<ViewManager>(ViewManager);
23
+ const PanelView = viewInstance.configurationPanel?.view;
24
+
25
+ const [treeView, setTreeView] = useState<SettingTreeView>();
26
+ useEffect(() => {
27
+ viewManager
28
+ .getOrCreateView(SettingTreeView)
29
+ .then((item) => {
30
+ setTreeView(item);
31
+ return;
32
+ })
33
+ .catch(console.error);
34
+ });
35
+
36
+ return (
37
+ <SplitPanel id="">
38
+ <SplitPanel.Pane className="" id="" defaultSize={200}>
39
+ {treeView && <ViewRender view={treeView} />}
40
+ </SplitPanel.Pane>
41
+ <SplitPanel.Pane className="" id="" flex={1}>
42
+ {PanelView && <PanelView />}
43
+ </SplitPanel.Pane>
44
+ </SplitPanel>
45
+ );
46
+ };
47
+
48
+ @singleton()
49
+ @view('SettingEditor')
50
+ export class SettingEditorView extends BaseView {
51
+ override view = SettingEditorComponent;
52
+
53
+ protected readonly configurationRegistry: ConfigurationRegistry;
54
+ protected readonly viewManager: ViewManager;
55
+
56
+ constructor(
57
+ @inject(ConfigurationRegistry) configurationRegistry: ConfigurationRegistry,
58
+ @inject(ViewManager) viewManager: ViewManager,
59
+ ) {
60
+ super();
61
+ this.configurationRegistry = configurationRegistry;
62
+ this.viewManager = viewManager;
63
+ }
64
+
65
+ @prop()
66
+ configurationPanel?: ConfigurationPanelView;
67
+
68
+ override async onViewMount() {
69
+ await this.initFileView();
70
+ await this.initPanel();
71
+ }
72
+
73
+ async initPanel() {
74
+ const namespace = this.configurationRegistry.getRootNamespaces().at(0);
75
+ if (namespace) {
76
+ this.configurationPanel =
77
+ await this.viewManager.getOrCreateView<ConfigurationPanelView>(
78
+ ConfigurationPanelView,
79
+ );
80
+ this.configurationPanel.configurationNodes =
81
+ this.configurationRegistry.getConfigurationByNamespace([namespace], false);
82
+ }
83
+ }
84
+
85
+ async initFileView() {
86
+ const treeView =
87
+ await this.viewManager.getOrCreateView<SettingTreeView>(SettingTreeView);
88
+ // if (!this.viewStorage.canStoreView) {
89
+ treeView.model.rootVisible = false;
90
+ treeView.model.location = new URI('file:///');
91
+ // }
92
+ }
93
+ }
@@ -0,0 +1,82 @@
1
+ import { inject, ConfigurationRegistry, URI } from '@difizen/mana-app';
2
+ import { FileService, singleton } from '@difizen/mana-app';
3
+ import type { FileStatWithMetadata } from '@difizen/mana-app';
4
+
5
+ const defaultFileMeta = {
6
+ mtime: 0,
7
+ ctime: 0,
8
+ etag: '',
9
+ size: 0,
10
+ isFile: false,
11
+ isDirectory: false,
12
+ isSymbolicLink: false,
13
+ };
14
+
15
+ @singleton({ contrib: FileService })
16
+ export class SettingTreeService extends FileService {
17
+ protected readonly configurationRegistry: ConfigurationRegistry;
18
+ constructor(
19
+ @inject(ConfigurationRegistry) configurationRegistry: ConfigurationRegistry,
20
+ ) {
21
+ super();
22
+ this.configurationRegistry = configurationRegistry;
23
+ }
24
+
25
+ override async resolve(
26
+ resource: URI,
27
+ // options?: ResolveFileOptions | undefined,
28
+ ): Promise<FileStatWithMetadata> {
29
+ if (resource.path.isRoot) {
30
+ const roots = this.configurationRegistry.getRootNamespaces().map((item) => {
31
+ return {
32
+ ...defaultFileMeta,
33
+ isFile: false,
34
+ isDirectory: true,
35
+ name: item,
36
+ resource: URI.resolve(resource, item),
37
+ };
38
+ });
39
+ return {
40
+ ...defaultFileMeta,
41
+ isDirectory: true,
42
+ name: resource.displayName,
43
+ resource,
44
+ children: roots,
45
+ };
46
+ }
47
+
48
+ const name = resource.path.name;
49
+
50
+ const namespaces = this.configurationRegistry
51
+ .getChildNamespaces([name])
52
+ .map((item) => {
53
+ return {
54
+ ...defaultFileMeta,
55
+ isFile: false,
56
+ isDirectory: true,
57
+ name: item.join('.'),
58
+ resource: URI.resolve(resource, item.join('.')),
59
+ };
60
+ });
61
+
62
+ const configs = this.configurationRegistry
63
+ .getConfigurationByNamespace([name])
64
+ .map((item) => {
65
+ return {
66
+ ...defaultFileMeta,
67
+ isFile: true,
68
+ name: item.title ?? '',
69
+ resource: URI.resolve(resource, item.id),
70
+ };
71
+ });
72
+
73
+ return {
74
+ ...defaultFileMeta,
75
+ isFile: false,
76
+ isDirectory: true,
77
+ name: resource.displayName,
78
+ resource,
79
+ children: [...namespaces, ...configs],
80
+ };
81
+ }
82
+ }
@@ -0,0 +1,95 @@
1
+ import {
2
+ CommandRegistry,
3
+ FileStatNode,
4
+ FileTreeModel,
5
+ FileTreeView,
6
+ FileTreeViewModule,
7
+ inject,
8
+ LabelProvider,
9
+ SelectionService,
10
+ singleton,
11
+ TreeDecoratorService,
12
+ TreeProps,
13
+ TreeViewComponent,
14
+ TreeViewDecorator,
15
+ view,
16
+ } from '@difizen/mana-app';
17
+ import type { TreeNode } from '@difizen/mana-app';
18
+ import { l10n } from '@difizen/mana-l10n';
19
+ import React, { forwardRef } from 'react';
20
+ import './index.less';
21
+
22
+ export const SettingTreeFactoryId = 'setting-editor-tree';
23
+ export const FileTreeComponent = forwardRef<HTMLDivElement, any>(
24
+ function FileTreeComponent(props, containerRef: React.ForwardedRef<HTMLDivElement>) {
25
+ return (
26
+ <div className="libro-configuration-tree" ref={containerRef}>
27
+ <div className="ai-infra-configuration-header">{l10n.t('文件')}</div>
28
+ <div className="libro-configuration-content">
29
+ <TreeViewComponent />
30
+ </div>
31
+ </div>
32
+ );
33
+ },
34
+ );
35
+
36
+ export const SettingTreeComponent: React.FC = () => {
37
+ return <></>;
38
+ };
39
+
40
+ function jump(h: string) {
41
+ const url = location.href; //Save down the URL without hash.
42
+ location.href = '#' + h; //Go to the target element.
43
+ history.replaceState(null, '', url); //Don't like hashes. Changing it back.
44
+ }
45
+
46
+ @singleton()
47
+ @view(SettingTreeFactoryId, FileTreeViewModule)
48
+ export class SettingTreeView extends FileTreeView {
49
+ protected command: CommandRegistry;
50
+ override readonly props: TreeProps;
51
+ override readonly model: FileTreeModel;
52
+ override readonly treeViewDecorator: TreeViewDecorator;
53
+ override readonly selectionService: SelectionService;
54
+ override readonly labelProvider: LabelProvider;
55
+ protected override readonly decoratorService: TreeDecoratorService;
56
+
57
+ constructor(
58
+ @inject(CommandRegistry) command: CommandRegistry,
59
+ @inject(TreeProps) props: TreeProps,
60
+ @inject(FileTreeModel) model: FileTreeModel,
61
+ @inject(TreeViewDecorator) treeViewDecorator: TreeViewDecorator,
62
+ @inject(SelectionService) selectionService: SelectionService,
63
+ @inject(LabelProvider) labelProvider: LabelProvider,
64
+ @inject(TreeDecoratorService)
65
+ decoratorService: TreeDecoratorService,
66
+ ) {
67
+ super(
68
+ props,
69
+ model,
70
+ treeViewDecorator,
71
+ selectionService,
72
+ labelProvider,
73
+ decoratorService,
74
+ );
75
+ this.command = command;
76
+ this.props = props;
77
+ this.model = model;
78
+ this.treeViewDecorator = treeViewDecorator;
79
+ this.selectionService = selectionService;
80
+ this.labelProvider = labelProvider;
81
+ this.decoratorService = decoratorService;
82
+
83
+ this.className += ` libro-configuration-tree`;
84
+ }
85
+
86
+ override handleClickEvent(
87
+ node: TreeNode | undefined,
88
+ event: React.MouseEvent<HTMLElement>,
89
+ ): void {
90
+ if (node && FileStatNode.is(node) && node.fileStat.isFile) {
91
+ jump(node.fileStat.resource.path.base);
92
+ }
93
+ super.handleClickEvent(node, event);
94
+ }
95
+ }
@@ -0,0 +1,24 @@
1
+ import { ModalContribution, singleton, ToolbarContribution } from '@difizen/mana-app';
2
+ import type { ToolbarRegistry } from '@difizen/mana-app';
3
+ import { l10n } from '@difizen/mana-l10n';
4
+
5
+ import { DocumentCommands } from '../command/document-commands.js';
6
+
7
+ import { SettingsModal } from './settings-modal.js';
8
+
9
+ @singleton({ contrib: [ModalContribution, ToolbarContribution] })
10
+ export class SettingsContribution implements ModalContribution, ToolbarContribution {
11
+ registerModal() {
12
+ return SettingsModal;
13
+ }
14
+
15
+ registerToolbarItems(registry: ToolbarRegistry) {
16
+ registry.registerItem({
17
+ id: DocumentCommands['OpenSettings'].id,
18
+ icon: DocumentCommands['OpenSettings'].icon,
19
+ command: DocumentCommands['OpenSettings'].id,
20
+ order: 'z',
21
+ tooltip: l10n.t('设置'),
22
+ });
23
+ }
24
+ }
@@ -0,0 +1,3 @@
1
+ .libro-settings-modal {
2
+ background-color: #fff !important;
3
+ }
@@ -0,0 +1,50 @@
1
+ import type { ModalItem, ModalItemProps } from '@difizen/mana-app';
2
+ import { ConfigurationRegistry } from '@difizen/mana-app';
3
+ import { useInject, ViewManager, ViewRender } from '@difizen/mana-app';
4
+ import { Modal } from 'antd';
5
+ import { useEffect, useState } from 'react';
6
+
7
+ import { ConfigurationPanelView } from './setting-editor/index.js';
8
+ import { LibroUserSettingsNamespace } from './settings-protocol.js';
9
+ import './settings-modal.less';
10
+
11
+ export function SettingsModalComponent({ visible, close }: ModalItemProps<void>) {
12
+ const viewManager = useInject(ViewManager);
13
+ const configRegistry = useInject(ConfigurationRegistry);
14
+ const [settingEditorView, setSettingEditorView] = useState<ConfigurationPanelView>();
15
+
16
+ useEffect(() => {
17
+ viewManager
18
+ .getOrCreateView<ConfigurationPanelView>(ConfigurationPanelView)
19
+ .then((view) => {
20
+ const config = configRegistry.getConfigurationByNamespace(
21
+ [LibroUserSettingsNamespace],
22
+ false,
23
+ );
24
+ view.configurationNodes = config;
25
+ view.className = 'libro-settings-modal';
26
+ setSettingEditorView(view);
27
+ return;
28
+ })
29
+ .catch((e) => {
30
+ //
31
+ });
32
+ }, [configRegistry, viewManager]);
33
+
34
+ return (
35
+ <Modal
36
+ title="设置"
37
+ open={visible}
38
+ onOk={() => close()}
39
+ onCancel={() => close()}
40
+ width={600}
41
+ >
42
+ {settingEditorView && <ViewRender view={settingEditorView} />}
43
+ </Modal>
44
+ );
45
+ }
46
+
47
+ export const SettingsModal: ModalItem = {
48
+ id: 'settings.modal',
49
+ component: SettingsModalComponent,
50
+ };
@@ -0,0 +1,7 @@
1
+ import type { ConfigurationStorage } from '@difizen/mana-app';
2
+
3
+ export const LibroUserSettingsNamespace = 'libro.user';
4
+ export const LibroUserSettingStorage: ConfigurationStorage = {
5
+ id: '__libro.user.storage__',
6
+ priority: 100,
7
+ };
@@ -9,15 +9,13 @@ import { LibroExtensionSlotContribution } from './libro-slot-protocol.js';
9
9
 
10
10
  @singleton()
11
11
  export class LibroSlotManager {
12
- protected slotViewManager: SlotViewManager;
12
+ @inject(SlotViewManager) slotViewManager: SlotViewManager;
13
13
  protected readonly libroExtraProvider: Contribution.Provider<LibroExtensionSlotContribution>;
14
14
  constructor(
15
- @inject(SlotViewManager) slotViewManager: SlotViewManager,
16
15
  @contrib(LibroExtensionSlotContribution)
17
16
  libroExtraProvider: Contribution.Provider<LibroExtensionSlotContribution>,
18
17
  ) {
19
18
  this.libroExtraProvider = libroExtraProvider;
20
- this.slotViewManager = slotViewManager;
21
19
  }
22
20
 
23
21
  getSlotName(libro: LibroView, slot: LibroSlot): string {
@@ -1,15 +1,12 @@
1
1
  import { DefaultSlotView, view, ViewRender, ViewInstance } from '@difizen/mana-app';
2
2
  import { transient } from '@difizen/mana-app';
3
3
  import { equals, prop, useInject } from '@difizen/mana-app';
4
- import React, { forwardRef } from 'react';
4
+ import { forwardRef } from 'react';
5
5
 
6
6
  import { isDisplayView } from './libro-slot-protocol.js';
7
7
 
8
8
  export const LibroExtensionViewComponent = forwardRef(
9
- function LibroExtensionViewComponent(
10
- _props,
11
- ref: React.ForwardedRef<HTMLDivElement>,
12
- ) {
9
+ function LibroExtensionViewComponent(props, ref: React.ForwardedRef<HTMLDivElement>) {
13
10
  const instance = useInject<LibroSlotView>(ViewInstance);
14
11
  //过滤出实现了DisplayView接口的View,用于控制抢占逻辑
15
12
  const filteredChildren = instance.children.filter((item) => {
@@ -366,6 +366,12 @@ export class LibroColorRegistry implements ColorContribution {
366
366
  defaults: { dark: '#788491', light: '#9f9f9f' },
367
367
  description: '',
368
368
  },
369
+
370
+ {
371
+ id: 'libro.cell.selected.bg.color',
372
+ defaults: { dark: '#353638', light: '#F1FAFF' },
373
+ description: '',
374
+ },
369
375
  );
370
376
  }
371
377
  }
@@ -0,0 +1,19 @@
1
+ import { useInject, ViewInstance } from '@difizen/mana-app';
2
+ import type { FC } from 'react';
3
+
4
+ import type { LibroView } from '../libro-view.js';
5
+ import { DisableOutputScroll } from '../material-from-designer.js';
6
+
7
+ export const AllOutputsScrollIcon: FC = () => {
8
+ const libroView = useInject<LibroView>(ViewInstance);
9
+
10
+ return (
11
+ <div
12
+ className={`libro-all-outputs-scroll-button ${
13
+ libroView.outputsScroll ? 'active' : ''
14
+ }`}
15
+ >
16
+ <DisableOutputScroll />
17
+ </div>
18
+ );
19
+ };
@@ -4,24 +4,41 @@ import {
4
4
  ModalService,
5
5
  singleton,
6
6
  ToolbarContribution,
7
+ useObserve,
7
8
  } from '@difizen/mana-app';
8
9
  import { l10n } from '@difizen/mana-l10n';
9
10
 
10
11
  import { DocumentCommands, NotebookCommands } from '../command/index.js';
12
+ import { LibroService } from '../libro-service.js';
11
13
 
14
+ import { AllOutputsScrollIcon } from './all-outputs-scroll-icon.js';
12
15
  import { ToolItemSelect } from './change-cell-to-selector.js';
13
16
  import { HideAllSelect } from './hide-all-selector.js';
14
17
  // import { RunSelect } from './run-selector';
15
18
  import { SaveIcon } from './save-icon.js';
16
19
  import { SideToolbarMoreSelect } from './side-toolar-more-select.js';
17
20
  // import { SideToolbarRunSelect } from './side-toolbar-run-select';
21
+
22
+ function OutputsScorllTooltip({ libroService }: { libroService: LibroService }) {
23
+ const service = useObserve(libroService);
24
+
25
+ return (
26
+ <div className="libro-tooltip">
27
+ <span className="libro-tooltip-text">
28
+ {l10n.t(
29
+ service.active?.outputsScroll
30
+ ? '取消固定 Output 展示高度'
31
+ : '固定 Output 展示高度',
32
+ )}
33
+ </span>
34
+ </div>
35
+ );
36
+ }
37
+
18
38
  @singleton({ contrib: [ToolbarContribution] })
19
39
  export class LibroToolbarContribution implements ToolbarContribution {
20
- protected readonly modalService: ModalService;
21
-
22
- constructor(@inject(ModalService) modalService: ModalService) {
23
- this.modalService = modalService;
24
- }
40
+ @inject(ModalService) protected readonly modalService: ModalService;
41
+ @inject(LibroService) protected readonly libroService: LibroService;
25
42
 
26
43
  registerToolbarItems(registry: ToolbarRegistry): void {
27
44
  registry.registerItem({
@@ -155,6 +172,14 @@ export class LibroToolbarContribution implements ToolbarContribution {
155
172
  group: ['group3'],
156
173
  order: 'h2',
157
174
  });
175
+ registry.registerItem({
176
+ id: NotebookCommands['EnableOrDisableAllOutputScrolling'].id,
177
+ command: NotebookCommands['EnableOrDisableAllOutputScrolling'].id,
178
+ tooltip: <OutputsScorllTooltip libroService={this.libroService} />,
179
+ group: ['group3'],
180
+ order: 'h2',
181
+ icon: AllOutputsScrollIcon,
182
+ });
158
183
  registry.registerItem({
159
184
  id: NotebookCommands['HideAllCell'].id,
160
185
  command: NotebookCommands['HideAllCell'].id,
@@ -5,11 +5,11 @@ import { useCallback } from 'react';
5
5
  import { NotebookCommands } from '../command/index.js';
6
6
  import type { LibroView } from '../libro-view.js';
7
7
 
8
- export const RestartClearOutputModalComponent: React.FC<ModalItemProps<LibroView>> = ({
8
+ export function RestartClearOutputModalComponent({
9
9
  visible,
10
10
  close,
11
11
  data,
12
- }: ModalItemProps<LibroView>) => {
12
+ }: ModalItemProps<LibroView>) {
13
13
  const handleRestart = useCallback(() => {
14
14
  data?.restartClearOutput();
15
15
  close();
@@ -29,7 +29,7 @@ export const RestartClearOutputModalComponent: React.FC<ModalItemProps<LibroView
29
29
  Do you want to restart the current kernel? All variables will be lost.
30
30
  </Modal>
31
31
  );
32
- };
32
+ }
33
33
 
34
34
  export const RestartClearOutputModal: ModalItem<LibroView> = {
35
35
  id: NotebookCommands['RestartClearOutput'].id,
@@ -5,11 +5,11 @@ import { useCallback } from 'react';
5
5
  import { NotebookCommands } from '../command/index.js';
6
6
  import type { LibroView } from '../libro-view.js';
7
7
 
8
- export const ShutdownModalComponent: React.FC<ModalItemProps<LibroView>> = ({
8
+ export function ShutdownModalComponent({
9
9
  visible,
10
10
  close,
11
11
  data,
12
- }: ModalItemProps<LibroView>) => {
12
+ }: ModalItemProps<LibroView>) {
13
13
  const handleShutdown = useCallback(() => {
14
14
  data?.closeAndShutdown();
15
15
  close();
@@ -29,7 +29,7 @@ export const ShutdownModalComponent: React.FC<ModalItemProps<LibroView>> = ({
29
29
  Do you want to shutdown the current kernel?.
30
30
  </Modal>
31
31
  );
32
- };
32
+ }
33
33
 
34
34
  export const ShutdownModal: ModalItem<LibroView> = {
35
35
  id: NotebookCommands['CloseAndShutdown'].id,
@@ -4,6 +4,7 @@ import {
4
4
  getOrigin,
5
5
  ToolbarInstance,
6
6
  useInject,
7
+ useObserve,
7
8
  } from '@difizen/mana-app';
8
9
  import { l10n } from '@difizen/mana-l10n';
9
10
  import { Menu, MenuContext } from '@difizen/mana-react';
@@ -93,7 +94,7 @@ export const LibroSideToolbarMoreMenu: React.FC = () => {
93
94
  const toolbar = useInject<Toolbar>(ToolbarInstance);
94
95
  const data = toolbar.currentArgs as LibroToolbarArags;
95
96
  const args = getOrigin(data) || [];
96
- const cell = args[0];
97
+ const cell = useObserve(args[0]);
97
98
  if (!cell) {
98
99
  return null;
99
100
  }
@@ -0,0 +1,29 @@
1
+ import { inject, prop, singleton } from '@difizen/mana-app';
2
+
3
+ import type { NotebookModel } from './libro-protocol.js';
4
+ import { VirtualizedManagerOptionFactory } from './libro-protocol.js';
5
+ import type { VirtualizedManager } from './virtualized-manager.js';
6
+
7
+ @singleton()
8
+ export class VirtualizedManagerHelper {
9
+ @inject(VirtualizedManagerOptionFactory) factory: VirtualizedManagerOptionFactory;
10
+
11
+ @prop()
12
+ current?: VirtualizedManager;
13
+ protected virtualizedManagerHelperMap = new Map<string, VirtualizedManager>();
14
+
15
+ setCurrent(libroModel: NotebookModel) {
16
+ const virtualizedManagerHelper = this.getOrCreate(libroModel);
17
+ this.current = virtualizedManagerHelper;
18
+ }
19
+
20
+ getOrCreate(libroModel: NotebookModel): VirtualizedManager {
21
+ const exist = this.virtualizedManagerHelperMap.get(libroModel.id);
22
+ if (exist) {
23
+ return exist;
24
+ }
25
+ const virtualizedManagerHelper = this.factory({ libroModel: libroModel });
26
+ this.virtualizedManagerHelperMap.set(libroModel.id, virtualizedManagerHelper);
27
+ return virtualizedManagerHelper;
28
+ }
29
+ }
@@ -0,0 +1,34 @@
1
+ import { transient, prop } from '@difizen/mana-app';
2
+
3
+ export interface IVirtualizedManager {
4
+ openVirtualized: (length: number, size?: number, path?: string) => Promise<boolean>;
5
+ isVirtualized: boolean;
6
+ }
7
+
8
+ @transient()
9
+ export class VirtualizedManager implements IVirtualizedManager {
10
+ /**
11
+ * 因为进行isVirtualized判断过后才会渲染list
12
+ * 所以它用于滚动到某个cell的判断依据是没有问题的。
13
+ */
14
+ @prop()
15
+ isVirtualized = false;
16
+ /**
17
+ *
18
+ * @param length cell个数
19
+ * @param size undefined 或者 单位 为B
20
+ * @returns 是否使用虚拟滚动
21
+ */
22
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
+ openVirtualized = async (length: number, size?: number, path?: string) => {
24
+ // this.isVirtualized = true;
25
+ // return true;
26
+ if (length > 100 || (size && size > 4)) {
27
+ this.isVirtualized = true;
28
+ return true;
29
+ } else {
30
+ this.isVirtualized = false;
31
+ return false;
32
+ }
33
+ };
34
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"libro-configuration-contribution.d.ts","sourceRoot":"","sources":["../../src/configuration/libro-configuration-contribution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAc9D,qBACa,8BAA+B,YAAW,yBAAyB;IAC9E,sBAAsB;CAYvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"libro-configuration.d.ts","sourceRoot":"","sources":["../../src/configuration/libro-configuration.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,OAAO,CAS3D,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,iBAAiB,CAAC,OAAO,CAS5D,CAAC;AAEF,eAAO,MAAM,sBAAsB,EAAE,iBAAiB,CAAC,OAAO,CAS7D,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,iBAAiB,CAAC,OAAO,CAS3D,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAAiB,CAAC,OAAO,CAS/D,CAAC;AACF,eAAO,MAAM,eAAe,EAAE,iBAAiB,CAAC,OAAO,CAStD,CAAC;AACF,eAAO,MAAM,4BAA4B,EAAE,iBAAiB,CAAC,OAAO,CASnE,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,iBAAiB,CAAC,OAAO,CASxD,CAAC"}