(ViewInstance);
+ const cell = instance.libro?.activeCell;
-// const insertCell = async (data: any) => {
-// const libro = instance.libro;
-// if (!libro) {
-// return;
-// }
-// const insertIndex = libro.model.cells.findIndex(
-// (c) => c.id === libro.activeCell?.id,
-// );
-// await libro.addCell(
-// {
-// id: v4(),
-// cell: { cell_type: 'code', source: data, metadata: {} },
-// },
-// insertIndex + 1,
-// );
-// };
+ const insertCell = async (data: any) => {
+ const libro = instance.libro;
+ if (!libro) {
+ return;
+ }
+ const insertIndex = libro.model.cells.findIndex(
+ (c) => c.id === libro.activeCell?.id,
+ );
+ await libro.addCell(
+ {
+ id: v4(),
+ cell: { cell_type: 'code', source: data, metadata: {} },
+ },
+ insertIndex + 1,
+ );
+ };
-// const replace = (data: any) => {
-// if (cell instanceof LibroCodeCellView && cell.editor) {
-// const length = cell.editor.model.value.length;
-// const start = cell.editor.getPositionAt(0);
-// const end = cell.editor.getPositionAt(length);
-// if (start && end) {
-// cell.editor.replaceSelection(data, {
-// start,
-// end,
-// });
-// }
-// }
-// };
+ const replace = (data: any) => {
+ if (cell instanceof LibroCodeCellView && cell.editor) {
+ const length = cell.editor.model.value.length;
+ const start = cell.editor.getPositionAt(0);
+ const end = cell.editor.getPositionAt(length);
+ if (start && end) {
+ cell.editor.replaceSelection(data, {
+ start,
+ end,
+ });
+ }
+ }
+ };
-// if (!props.inline && className) {
-// const [, lang] = /language-(\w+)/.exec(className || '') || [];
+ if (!props.inline && className) {
+ const [, lang] = /language-(\w+)/.exec(className || '') || [];
-// return (
-//
-// {lang && {lang}
}
-// {
-// copy(children);
-// message.success(l10n.t('代码已复制'));
-// }}
-// className={`chat-msg-md-code-copy`}
-// />
-//
-// {typeof children === 'string' ? children.trim() : children}
-//
-//
-//
-//
-//
-//
-// );
-// }
+ return (
+
+ {lang && {lang}
}
+ {
+ copy(children);
+ message.success(l10n.t('代码已复制'));
+ }}
+ className={`chat-msg-md-code-copy`}
+ />
+
+ {typeof children === 'string' ? children.trim() : children}
+
+
+
+
+
+
+ );
+ }
-// return {children}
;
-// };
+ return {children}
;
+};
diff --git a/packages/libro-ai-native/src/module.ts b/packages/libro-ai-native/src/module.ts
index 6f2db6cd..480a733c 100644
--- a/packages/libro-ai-native/src/module.ts
+++ b/packages/libro-ai-native/src/module.ts
@@ -1,8 +1,8 @@
import { CodeEditorModule } from '@difizen/libro-code-editor';
import { ManaModule } from '@difizen/libro-common/app';
import { CellOutputTopProvider, ErrorOutputModel } from '@difizen/libro-jupyter';
-// import { ChatView } from '@difizen/magent-chat';
-// import { LibroChatModule, LibroChatService } from '@difizen/magent-libro';
+import { ChatView } from '@difizen/magent-chat';
+import { LibroChatModule, LibroChatService } from '@difizen/magent-libro';
import { LibroAICompletionModule } from './ai-inline-completions/module.js';
import { LibroAINativeCommandContribution } from './ai-native-command-contribution.js';
@@ -13,8 +13,8 @@ import { LibroAIChatSlotContribution } from './chat-slot-contribution.js';
import { LibroChatView } from './chat-view.js';
import { AIErrorOutputModel } from './error-output-model.js';
import { LibroAIChatMessageItemModel } from './libro-ai-msg-item-model.js';
-// import { LibroAINativeChatService } from './libro-ai-native-chat-service.js';
-// import { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
+import { LibroAINativeChatService } from './libro-ai-native-chat-service.js';
+import { LibroAiNativeChatView } from './libro-ai-native-chat-view.js';
import { LibroAINativeColorRegistry } from './libro-ai-native-color-registry.js';
export const LibroAINativeModuleSetting = {
@@ -29,23 +29,23 @@ export const LibroAINativeModule = ManaModule.create()
LibroAINativeCommandContribution,
LibroAINativeService,
LibroAIChatMessageItemModel,
- // LibroAINativeForCellView,
+ LibroAINativeForCellView,
{
token: ErrorOutputModel,
useClass: AIErrorOutputModel,
},
- // {
- // token: ChatView,
- // useClass: LibroAiNativeChatView,
- // },
- // {
- // token: LibroChatService,
- // useClass: LibroAINativeChatService,
- // },
+ {
+ token: ChatView,
+ useClass: LibroAiNativeChatView,
+ },
+ {
+ token: LibroChatService,
+ useClass: LibroAINativeChatService,
+ },
{
token: CellOutputTopProvider,
useValue: LibroAINativeCellTopBlank,
},
)
.canload(() => Promise.resolve(LibroAINativeModuleSetting.loadable))
- .dependOn(CodeEditorModule, LibroAICompletionModule);
+ .dependOn(LibroChatModule, CodeEditorModule, LibroAICompletionModule);