Skip to content

Commit 451285b

Browse files
committed
fix: organize context as props
1 parent 9ed9490 commit 451285b

File tree

3 files changed

+30
-9
lines changed

3 files changed

+30
-9
lines changed
Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
diff --git a/node_modules/react-vsc-treeview/dist/TreeItem.js b/node_modules/react-vsc-treeview/dist/TreeItem.js
2-
index 91d695c..cb524fa 100644
2+
index 91d695c..ab6698d 100644
33
--- a/node_modules/react-vsc-treeview/dist/TreeItem.js
44
+++ b/node_modules/react-vsc-treeview/dist/TreeItem.js
55
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
66
const vscode = __importStar(require("vscode"));
77
const react_1 = __importStar(require("react"));
88
const VSCTreeItem_1 = __importDefault(require("./VSCTreeItem"));
99
-const TreeItem = ({ label = '', id, iconPath, description, resourceUri, tooltip, command: rawCommand, contextValue, expanded, children }) => {
10-
+const TreeItem = ({ label = '', id, iconPath, description, resourceUri, tooltip, command: rawCommand, contextValue, expanded, children, ...otherProps }) => {
10+
+const TreeItem = ({ label = '', id, iconPath, description, resourceUri, tooltip, command: rawCommand, contextValue, expanded, children, context }) => {
1111
const collapsibleState = react_1.useMemo(() => {
1212
if (children == null) {
1313
return vscode.TreeItemCollapsibleState.None;
@@ -17,28 +17,41 @@ index 91d695c..cb524fa 100644
1717
collapsibleState,
1818
- contextValue
1919
+ contextValue,
20-
+ ...otherProps
20+
+ context
2121
};
2222
return react_1.default.createElement(VSCTreeItem_1.default, Object.assign({}, vscTreeItemProps), children);
2323
};
24+
diff --git a/node_modules/react-vsc-treeview/dist/VSCTreeItem.js b/node_modules/react-vsc-treeview/dist/VSCTreeItem.js
25+
index 9f3174b..4504944 100644
26+
--- a/node_modules/react-vsc-treeview/dist/VSCTreeItem.js
27+
+++ b/node_modules/react-vsc-treeview/dist/VSCTreeItem.js
28+
@@ -16,6 +16,6 @@ const VSCTreeItem = (props) => {
29+
exports.default = VSCTreeItem;
30+
exports.propKeys = [
31+
'label', 'id', 'iconPath', 'description', 'resourceUri', 'tooltip',
32+
- 'command', 'collapsibleState', 'contextValue', 'children'
33+
+ 'command', 'collapsibleState', 'contextValue', 'children', 'context'
34+
];
35+
//# sourceMappingURL=VSCTreeItem.js.map
36+
\ No newline at end of file
2437
diff --git a/node_modules/react-vsc-treeview/dist/reconciler.js b/node_modules/react-vsc-treeview/dist/reconciler.js
25-
index 7ee5f2d..bfead5a 100644
38+
index 7ee5f2d..7b97e33 100644
2639
--- a/node_modules/react-vsc-treeview/dist/reconciler.js
2740
+++ b/node_modules/react-vsc-treeview/dist/reconciler.js
2841
@@ -28,7 +28,7 @@ const VSCTreeItem_1 = require("./VSCTreeItem");
2942
exports.default = react_reconciler_1.default({
3043
supportsMutation: true,
3144
createInstance(_type, props, container) {
3245
- const { label = '', id, iconPath, description, resourceUri, tooltip, command, collapsibleState, contextValue } = props;
33-
+ const { label = '', id, iconPath, description, resourceUri, tooltip, command, collapsibleState, contextValue, ...otherProps } = props;
46+
+ const { label = '', id, iconPath, description, resourceUri, tooltip, command, collapsibleState, contextValue, context } = props;
3447
const treeItem = new vscode.TreeItem(label, collapsibleState);
3548
treeItem.id = id;
3649
treeItem.iconPath = iconPath;
3750
@@ -37,6 +37,7 @@ exports.default = react_reconciler_1.default({
3851
treeItem.tooltip = tooltip;
3952
treeItem.command = command;
4053
treeItem.contextValue = contextValue;
41-
+ treeItem.context = otherProps;
54+
+ treeItem.context = context;
4255
return container.createTreeItem(treeItem);
4356
},
4457
appendChildToContainer(container, child) {

src/@types/react-vsc-treeview.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ declare module 'react-vsc-treeview' {
33
import { TreeItemProps } from 'react-vsc-treeview/dist/TreeItem';
44

55
export const TreeItem: (
6-
props: TreeItemProps & { key?: any; children?: React.ReactNode; ref?: any } & Record<string, any>
6+
props: TreeItemProps & { key?: any; children?: React.ReactNode; context?: Record<string, any> }
77
) => React.ReactElement;
88
}

src/treeReactApp/components/NoteTreeItem.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { Note } from '@hackmd/api/dist/type';
2+
import { useMemo } from 'react';
23
import { TreeItem } from 'react-vsc-treeview';
34

45
export const NoteTreeItem = ({ note }: { note: Note }) => {
6+
const context = useMemo(
7+
() => ({
8+
publishLink: note.publishLink,
9+
noteId: note.id,
10+
}),
11+
[note]
12+
);
13+
514
return (
615
<TreeItem
716
label={note.title}
@@ -12,8 +21,7 @@ export const NoteTreeItem = ({ note }: { note: Note }) => {
1221
arguments: [note.title, note.id],
1322
}}
1423
contextValue="file"
15-
publishLink={note.id}
16-
noteId={note.id}
24+
context={context}
1725
/>
1826
);
1927
};

0 commit comments

Comments
 (0)