Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Feat 2.x diff editor #902

Open
wants to merge 3 commits into
base: 2.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions app/src/components/testPane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,27 @@ export default function TestPane({ context: molecule }: { context: IMoleculeCont
molecule.editor.open(tabData, molecule.editor.getState().groups?.at(0)?.id);
};

const newDiffEditor = function () {
const key = randomId();
const name = `editor-${key}.ts`;
const tabData: IEditorTab<any> = {
id: key,
name,
icon: 'file',
language: 'typescript',
isDiff: true,
originalValue: '// this is original content',
modifiedValue: '// this is modified content',
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

感觉这么写有点复杂,考虑直接 value 是 string 则 Editor,如果是 [string, string] 或者其他类型则为 DiffEditor 吧。

breadcrumb: [
{ id: 'app', name: 'app' },
{ id: 'src', name: 'src' },
{ id: 'components', name: 'components' },
{ id: 'editor', name, icon: 'file' },
],
};
molecule.editor.open(tabData, molecule.editor.getState().groups?.at(0)?.id);
};

const newCustomEditor = function () {
const key = randomId();
const name = `editor-${key}.ts`;
Expand Down Expand Up @@ -418,6 +439,9 @@ export default function TestPane({ context: molecule }: { context: IMoleculeCont
<components.Button block onClick={newEditor}>
New Editor
</components.Button>
<components.Button block onClick={newDiffEditor}>
New Diff Editor
</components.Button>
<components.Button block onClick={newCustomEditor}>
New Custom Editor
</components.Button>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
"devDependencies": {
"@dtinsight/molecule": "./",
"@types/lodash-es": "^4.17.8",
"@types/node": "^20.4.7",
"@types/node": "20.4.7",
"@types/react": "^18.2.18",
"@types/react-dom": "^18.2.7",
"@types/use-sync-external-store": "^0.0.6",
Expand Down
Loading