Skip to content

Commit

Permalink
fix: fix editor tabbar style (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain authored Aug 21, 2024
1 parent ea4e023 commit c9c6154
Show file tree
Hide file tree
Showing 14 changed files with 526 additions and 518 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"description": "codeblitzjs",
"main": "index.js",
"engines": {
"opensumi": "3.2.4-next-1723531705.0"
"opensumi": "3.2.5-next-1724135016.0"
},
"scripts": {
"prepare": "husky install",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"opensumi codeblitzjs"
],
"engines": {
"opensumi": "3.2.4-next-1723531705.0",
"opensumi": "3.2.5-next-1724135016.0",
"node": ">=10.0.0"
},
"dependencies": {
"@codeblitzjs/ide-common": "workspace:*",
"@opensumi/extension-installer": "^0.0.1",
"@opensumi/ide-extension": "3.2.4-next-1723531705.0",
"@opensumi/ide-extension": "3.2.5-next-1724135016.0",
"commander": "^7.2.0",
"fs-extra": "^9.0.1",
"lodash.pick": "^4.4.0",
Expand Down
84 changes: 42 additions & 42 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@
"@codeblitzjs/ide-plugin": "workspace:*",
"@codeblitzjs/ide-registry": "workspace:*",
"@codeblitzjs/ide-sumi-core": "workspace:*",
"@opensumi/ide-addons": "3.2.4-next-1723531705.0",
"@opensumi/ide-ai-native": "3.2.4-next-1723531705.0",
"@opensumi/ide-comments": "3.2.4-next-1723531705.0",
"@opensumi/ide-core-browser": "3.2.4-next-1723531705.0",
"@opensumi/ide-core-common": "3.2.4-next-1723531705.0",
"@opensumi/ide-debug": "3.2.4-next-1723531705.0",
"@opensumi/ide-decoration": "3.2.4-next-1723531705.0",
"@opensumi/ide-design": "3.2.4-next-1723531705.0",
"@opensumi/ide-editor": "3.2.4-next-1723531705.0",
"@opensumi/ide-explorer": "3.2.4-next-1723531705.0",
"@opensumi/ide-express-file-server": "3.2.4-next-1723531705.0",
"@opensumi/ide-extension": "3.2.4-next-1723531705.0",
"@opensumi/ide-extension-storage": "3.2.4-next-1723531705.0",
"@opensumi/ide-file-scheme": "3.2.4-next-1723531705.0",
"@opensumi/ide-file-service": "3.2.4-next-1723531705.0",
"@opensumi/ide-file-tree-next": "3.2.4-next-1723531705.0",
"@opensumi/ide-i18n": "3.2.4-next-1723531705.0",
"@opensumi/ide-keymaps": "3.2.4-next-1723531705.0",
"@opensumi/ide-logs": "3.2.4-next-1723531705.0",
"@opensumi/ide-main-layout": "3.2.4-next-1723531705.0",
"@opensumi/ide-markdown": "3.2.4-next-1723531705.0",
"@opensumi/ide-markers": "3.2.4-next-1723531705.0",
"@opensumi/ide-menu-bar": "3.2.4-next-1723531705.0",
"@opensumi/ide-monaco": "3.2.4-next-1723531705.0",
"@opensumi/ide-monaco-enhance": "3.2.4-next-1723531705.0",
"@opensumi/ide-opened-editor": "3.2.4-next-1723531705.0",
"@opensumi/ide-outline": "3.2.4-next-1723531705.0",
"@opensumi/ide-output": "3.2.4-next-1723531705.0",
"@opensumi/ide-overlay": "3.2.4-next-1723531705.0",
"@opensumi/ide-preferences": "3.2.4-next-1723531705.0",
"@opensumi/ide-quick-open": "3.2.4-next-1723531705.0",
"@opensumi/ide-scm": "3.2.4-next-1723531705.0",
"@opensumi/ide-search": "3.2.4-next-1723531705.0",
"@opensumi/ide-status-bar": "3.2.4-next-1723531705.0",
"@opensumi/ide-storage": "3.2.4-next-1723531705.0",
"@opensumi/ide-testing": "3.2.4-next-1723531705.0",
"@opensumi/ide-theme": "3.2.4-next-1723531705.0",
"@opensumi/ide-toolbar": "3.2.4-next-1723531705.0",
"@opensumi/ide-variable": "3.2.4-next-1723531705.0",
"@opensumi/ide-webview": "3.2.4-next-1723531705.0",
"@opensumi/ide-workspace": "3.2.4-next-1723531705.0",
"@opensumi/ide-workspace-edit": "3.2.4-next-1723531705.0",
"@opensumi/ide-addons": "3.2.5-next-1724135016.0",
"@opensumi/ide-ai-native": "3.2.5-next-1724135016.0",
"@opensumi/ide-comments": "3.2.5-next-1724135016.0",
"@opensumi/ide-core-browser": "3.2.5-next-1724135016.0",
"@opensumi/ide-core-common": "3.2.5-next-1724135016.0",
"@opensumi/ide-debug": "3.2.5-next-1724135016.0",
"@opensumi/ide-decoration": "3.2.5-next-1724135016.0",
"@opensumi/ide-design": "3.2.5-next-1724135016.0",
"@opensumi/ide-editor": "3.2.5-next-1724135016.0",
"@opensumi/ide-explorer": "3.2.5-next-1724135016.0",
"@opensumi/ide-express-file-server": "3.2.5-next-1724135016.0",
"@opensumi/ide-extension": "3.2.5-next-1724135016.0",
"@opensumi/ide-extension-storage": "3.2.5-next-1724135016.0",
"@opensumi/ide-file-scheme": "3.2.5-next-1724135016.0",
"@opensumi/ide-file-service": "3.2.5-next-1724135016.0",
"@opensumi/ide-file-tree-next": "3.2.5-next-1724135016.0",
"@opensumi/ide-i18n": "3.2.5-next-1724135016.0",
"@opensumi/ide-keymaps": "3.2.5-next-1724135016.0",
"@opensumi/ide-logs": "3.2.5-next-1724135016.0",
"@opensumi/ide-main-layout": "3.2.5-next-1724135016.0",
"@opensumi/ide-markdown": "3.2.5-next-1724135016.0",
"@opensumi/ide-markers": "3.2.5-next-1724135016.0",
"@opensumi/ide-menu-bar": "3.2.5-next-1724135016.0",
"@opensumi/ide-monaco": "3.2.5-next-1724135016.0",
"@opensumi/ide-monaco-enhance": "3.2.5-next-1724135016.0",
"@opensumi/ide-opened-editor": "3.2.5-next-1724135016.0",
"@opensumi/ide-outline": "3.2.5-next-1724135016.0",
"@opensumi/ide-output": "3.2.5-next-1724135016.0",
"@opensumi/ide-overlay": "3.2.5-next-1724135016.0",
"@opensumi/ide-preferences": "3.2.5-next-1724135016.0",
"@opensumi/ide-quick-open": "3.2.5-next-1724135016.0",
"@opensumi/ide-scm": "3.2.5-next-1724135016.0",
"@opensumi/ide-search": "3.2.5-next-1724135016.0",
"@opensumi/ide-status-bar": "3.2.5-next-1724135016.0",
"@opensumi/ide-storage": "3.2.5-next-1724135016.0",
"@opensumi/ide-testing": "3.2.5-next-1724135016.0",
"@opensumi/ide-theme": "3.2.5-next-1724135016.0",
"@opensumi/ide-toolbar": "3.2.5-next-1724135016.0",
"@opensumi/ide-variable": "3.2.5-next-1724135016.0",
"@opensumi/ide-webview": "3.2.5-next-1724135016.0",
"@opensumi/ide-workspace": "3.2.5-next-1724135016.0",
"@opensumi/ide-workspace-edit": "3.2.5-next-1724135016.0",
"@opensumi/textmate-languages": "^2.7.0",
"tslib": "^2.2.0"
},
Expand Down
51 changes: 31 additions & 20 deletions packages/core/src/api/normalize.less
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
// @opensumi/ide-core-browser/lib/style/normilize.less
@scrollbarwidth: 10px;

codeblitz-root {
margin: 0;
padding: 0;
// 使用该字体获取与vscode一致的图标表现
// 仅mac下可用,windows待区分
// https://stackoverflow.com/questions/32660748/how-to-use-apples-new-san-francisco-font-on-a-webpage
font-family: -apple-system, BlinkMacSystemFont, sans-serif;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe WPC', 'Segoe UI', system-ui, 'Ubuntu', 'Droid Sans', sans-serif;
// 全局默认字体颜色
color: var(--foreground);
background-color: var(--editor-background);
font-size: var(--base-font-size);
// 设置 antialiased 会导致整体清晰度降低
-webkit-font-smoothing: antialiased;
}

codeblitz-root {
/* 防止 overlay/modal 撑开页面元素 */
overflow: hidden;
/* 防止mac上的回退手势 */
/* 防止 mac 上的回退手势 */
overscroll-behavior-x: none;

input::placeholder,
Expand All @@ -25,16 +22,22 @@ codeblitz-root {

// 全局设置滚动条样式
::-webkit-scrollbar {
-webkit-appearance: none;

background: transparent;
width: 10px;
height: 10px;
width: @scrollbarwidth;
height: @scrollbarwidth;
}

::-webkit-scrollbar:hover {
background: transparent;
width: @scrollbarwidth;
height: @scrollbarwidth;
}

::-webkit-scrollbar-thumb {
transition: all 1s;

background: var(--scrollbarSlider-background);
}

Expand All @@ -52,6 +55,7 @@ codeblitz-root {

a {
color: var(--textLink-foreground);

&:hover,
&:active,
&:focus {
Expand All @@ -63,26 +67,33 @@ codeblitz-root {
background-color: var(--textBlockQuote-background);
border-color: var(--textBlockQuote-border);
}

code {
background-color: var(--textCodeBlock-background);
}

li {
list-style: none;
}
/* ---- 该样式主要用于让带 tabindex='-1' 的元素焦点态时拥有高亮边框,以便于实现如Tree,List组件焦点态时的自动高亮边框效果 ---- */
[tabindex='-1'] {
&:focus {
outline-width: 1px;
outline-style: solid;
outline-offset: -1px;
}
}

/* ---- 该样式主要用于让带 tabindex='-1' 的元素焦点态时拥有高亮边框,以便于实现如Tree,List组件焦点态时的自动高亮边框效果 ---- */
[tabindex='-1'] {
&:focus {
outline-width: 1px;
outline-style: solid;
outline-offset: -1px;
}
/* -------- */
}
/* -------- */

::selection {
color: inherit;
background-color: var(--selection-background);
}

:root {
--base-font-size: 13px;
--tabBar-height: 35px;
overflow-x: overlay;
overflow-y: overlay;
}
6 changes: 4 additions & 2 deletions packages/core/src/api/renderDiffViewer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ import React from 'react';
import { IDiffViewerProps } from '../core/diff-viewer';
import { DiffViewerModule } from '../core/diff-viewer/module';
import { BoxPanel, SplitPanel } from '../editor';
import { Injector } from '../modules/opensumi__common-di';
import { Injector } from '@opensumi/di';
import { AppRenderer, IAppRendererProps } from './renderApp';
import '../core/diff-viewer/languages-patch';
import { extensionMetadata } from '../core/diff-viewer/extension-patch';

export {
IDiffViewerHandle,
IDiffViewerProps,
} from '../core/diff-viewer/common';
export type {
IDiffViewerHandle,
IDiffViewerTab,
IExtendPartialEditEvent,
} from '../core/diff-viewer/common';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/diff-viewer/common.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IPluginConfig } from '@codeblitzjs/ide-plugin';
import { IAppOpts, RuntimeConfig } from '@codeblitzjs/ide-sumi-core';
import { IPartialEditEvent } from '@opensumi/ide-ai-native/lib/browser/widget/inline-stream-diff/live-preview.decoration';
import { IPartialEditEvent } from '@opensumi/ide-ai-native/lib/browser/widget/inline-stream-diff/live-preview.component';
import { Event, URI } from '@opensumi/ide-core-common';
import { IResourceOpenOptions } from '@opensumi/ide-editor';
import { ITheme } from '@opensumi/ide-theme';
Expand Down
25 changes: 10 additions & 15 deletions packages/core/src/core/diff-viewer/internal/base.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isFilesystemReady } from '@codeblitzjs/ide-sumi-core';
import { fsExtra, isFilesystemReady } from '@codeblitzjs/ide-sumi-core';
import { InlineChatHandler } from '@opensumi/ide-ai-native/lib/browser/widget/inline-chat/inline-chat.handler';
import { AppConfig, ClientAppContribution, EDITOR_COMMANDS, IClientApp } from '@opensumi/ide-core-browser';
import {
Expand All @@ -15,19 +15,16 @@ import {
import { IResourceOpenOptions, WorkbenchEditorService } from '@opensumi/ide-editor';
import { Selection, SelectionDirection } from '@opensumi/ide-monaco';

import { Autowired } from '@opensumi/di';
import { LiveInlineDiffPreviewer } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff-previewer';
import { InlineDiffHandler } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff.handler';
import { EResultKind } from '@opensumi/ide-ai-native/lib/common';
import { IMenuRegistry, MenuContribution } from '@opensumi/ide-core-browser/lib/menu/next';
import { IEditor, IEditorDocumentModelService } from '@opensumi/ide-editor/lib/browser';
import { requireModule } from '../../../api/require';
import { Autowired, Injectable } from '../../../modules/opensumi__common-di';
import { IMenuRegistry, MenuContribution } from '../../../modules/opensumi__ide-core-browser';
import path from 'path';
import { IDiffViewerProps, IDiffViewerTab, IExtendPartialEditEvent, ITabChangedEvent } from '../common';
import { removeStart } from '../utils';

const fse = requireModule('fs-extra');
const path = requireModule('path');

@Domain(CommandContribution, ClientAppContribution, MenuContribution)
export class DiffViewerContribution implements CommandContribution, ClientAppContribution, MenuContribution {
private _disposables = new DisposableStore();
Expand Down Expand Up @@ -78,9 +75,9 @@ export class DiffViewerContribution implements CommandContribution, ClientAppCon

const openFileInTab = async (filePath: string, content: string, options?: IResourceOpenOptions) => {
const fullPath = this.getFullPath(filePath);
if (!fse.pathExistsSync(fullPath)) {
fse.ensureFileSync(fullPath);
fse.writeFileSync(fullPath, content);
if (!fsExtra.pathExistsSync(fullPath)) {
fsExtra.ensureFileSync(fullPath);
fsExtra.writeFileSync(fullPath, content);
}

const uri = URI.file(fullPath);
Expand Down Expand Up @@ -108,7 +105,7 @@ export class DiffViewerContribution implements CommandContribution, ClientAppCon
const editor = openResourceResult.group.codeEditor;

if (oldContent === newContent) {
this.inlineDiffHandler.hidePreviewer(editor.monacoEditor);
this.inlineDiffHandler.destroyPreviewer();
return;
}

Expand All @@ -129,7 +126,7 @@ export class DiffViewerContribution implements CommandContribution, ClientAppCon
disposeWhenEditorClosed: false,
},
) as LiveInlineDiffPreviewer;
const whenReady = Event.toPromise(previewer.getNode().onDidEditChange);
const whenReady = Event.toPromise(previewer.getNode()!.onDidEditChange);

previewer.setValue(newContent);

Expand Down Expand Up @@ -206,20 +203,18 @@ export class DiffViewerContribution implements CommandContribution, ClientAppCon
},
getFileContent: async (filePath: string) => {
const fullPath = this.getFullPath(filePath);
return await fse.readFile(fullPath, 'utf-8');
return await fsExtra.readFile(fullPath, 'utf-8');
},
acceptAllPartialEdit: async () => {
if (this.inlineDiffHandler) {
this.inlineDiffHandler.handleAction(
this.workbenchEditorService.currentEditor!.monacoEditor,
EResultKind.ACCEPT,
);
}
},
rejectAllPartialEdit: async () => {
if (this.inlineDiffHandler) {
this.inlineDiffHandler.handleAction(
this.workbenchEditorService.currentEditor!.monacoEditor,
EResultKind.DISCARD,
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Autowired } from '@opensumi/di';
import { PreferenceProvider } from '@opensumi/ide-core-browser';
import { Domain, GeneralSettingsId, PreferenceScope } from '@opensumi/ide-core-common';
import { ITheme, ThemeContributionProvider } from '@opensumi/ide-theme';
import { IThemeService } from '@opensumi/ide-theme';
import { Autowired } from '../../../modules/opensumi__common-di';
import { IDiffViewerProps } from '../common';

@Domain(ThemeContributionProvider)
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/core/diff-viewer/module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BrowserModule } from '@opensumi/ide-core-browser';

import { Injectable } from '../../modules/opensumi__common-di';
import { Injectable } from '@opensumi/di';
import { DiffViewerContribution } from './internal/base';
import { DiffViewerComponentContribution } from './internal/component.provider';
import { DiffViewerThemeProvider } from './internal/theme.provider';
Expand Down
1 change: 0 additions & 1 deletion packages/startup/src/diff-viewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { IPartialEditEvent } from '@opensumi/ide-ai-native/lib/browser/widget/inline-stream-diff/live-preview.decoration';
import React, { useMemo, useRef } from 'react';
import { createRoot } from 'react-dom/client';

Expand Down
Loading

0 comments on commit c9c6154

Please sign in to comment.