Skip to content

Commit

Permalink
fix(lab): click to open file
Browse files Browse the repository at this point in the history
  • Loading branch information
xujingli committed Jan 24, 2024
1 parent 2744da3 commit 2cd7e6f
Showing 1 changed file with 1 addition and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { CloseOutlined } from '@ant-design/icons';
import { renderNode, useInject, ViewContext, ViewInstance } from '@difizen/mana-app';
import { OpenerService, URI } from '@difizen/mana-app';

import type { SaveableTabView } from '../../index.js';

export const OpenedTabs: React.FC = () => {
const tabs = useInject<SaveableTabView>(ViewInstance);
const openService = useInject<OpenerService>(OpenerService);

const renderTitleIcon = renderNode;
const renderTitleLabel = renderNode;
Expand All @@ -20,29 +18,7 @@ export const OpenedTabs: React.FC = () => {
title={item.title.caption}
className="libro-panel-collapse-item"
onClick={() => {
if (!item.filePath) {
return;
}

const path = item.filePath;
const name = item.title.label;

const uri = new URI(path);
openService
.getOpener(uri)
.then((opener) => {
if (opener) {
opener.open(uri, {
viewOptions: {
name: name,
},
});
}
return;
})
.catch((e) => {
console.error(e);
});
tabs.onChange(item.id);
}}
>
{item.title.icon && (
Expand Down

0 comments on commit 2cd7e6f

Please sign in to comment.