@opensumi/ide-overlay 2.21.13 → 2.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/ctx-menu/ctx-menu.service.js.map +1 -1
- package/lib/browser/dialog.contextkey.js.map +1 -1
- package/lib/browser/dialog.contribution.js.map +1 -1
- package/lib/browser/dialog.service.js.map +1 -1
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/message.service.js.map +1 -1
- package/package.json +9 -8
- package/src/browser/ctx-menu/ctx-menu.service.ts +53 -0
- package/src/browser/ctx-menu/ctx-menu.view.tsx +53 -0
- package/src/browser/dialog.contextkey.ts +18 -0
- package/src/browser/dialog.contribution.ts +43 -0
- package/src/browser/dialog.service.ts +110 -0
- package/src/browser/dialog.view.tsx +65 -0
- package/src/browser/index.ts +38 -0
- package/src/browser/index.view.tsx +49 -0
- package/src/browser/message.module.less +0 -0
- package/src/browser/message.service.tsx +81 -0
- package/src/browser/styles.module.less +8 -0
- package/src/common/index.ts +134 -0
- package/src/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ctx-menu.service.js","sourceRoot":"","sources":["../../../src/browser/ctx-menu/ctx-menu.service.ts"],"names":[],"mappings":";;;;AAAA,+BAA0C;AAE1C,qCAA0C;
|
|
1
|
+
{"version":3,"file":"ctx-menu.service.js","sourceRoot":"","sources":["../../../src/browser/ctx-menu/ctx-menu.service.ts"],"names":[],"mappings":";;;;AAAA,+BAA0C;AAE1C,qCAA0C;AAMnC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAA3B;QAEL,YAAO,GAAG,KAAK,CAAC;QAGhB,WAAM,GAA8C,SAAS,CAAC;QAG9D,UAAK,GAAiD,SAAS,CAAC;QAGhE,YAAO,GAAQ,SAAS,CAAC;QAGzB,cAAS,GAAe,iBAAU,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IA8B/C,CAAC;IA3BQ,IAAI,CAAC,OAA4B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DAMZ;AAED;IAAC,aAAM,CAAC,KAAK;;;;kDAGZ;AA3CU,qBAAqB;IADjC,IAAA,eAAU,GAAE;GACA,qBAAqB,CA4CjC;AA5CY,sDAAqB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.contextkey.js","sourceRoot":"","sources":["../../src/browser/dialog.contextkey.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,iEAA6E;AAC7E,6EAA4F;
|
|
1
|
+
{"version":3,"file":"dialog.contextkey.js","sourceRoot":"","sources":["../../src/browser/dialog.contextkey.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AACrD,iEAA6E;AAC7E,6EAA4F;AAGrF,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAQ3B;QACE,IAAI,CAAC,kBAAkB,GAAG,IAAI,CAAC,uBAAuB,CAAC;QACvD,IAAI,CAAC,wBAAwB,GAAG,iCAAwB,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IACzF,CAAC;CACF,CAAA;AAXC;IAAC,IAAA,cAAS,EAAC,qCAAkB,CAAC;;iEAC+B;AAFlD,gBAAgB;IAD5B,IAAA,eAAU,GAAE;;GACA,gBAAgB,CAY5B;AAZY,4CAAgB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.contribution.js","sourceRoot":"","sources":["../../src/browser/dialog.contribution.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AACzC,iEAQoC;AACpC,6EAA4F;AAE5F,sCAA2C;
|
|
1
|
+
{"version":3,"file":"dialog.contribution.js","sourceRoot":"","sources":["../../src/browser/dialog.contribution.ts"],"names":[],"mappings":";;;;AAAA,qCAAyC;AACzC,iEAQoC;AACpC,6EAA4F;AAE5F,sCAA2C;AAGpC,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAI7B,gBAAgB,CAAC,QAAyB;QACxC,QAAQ,CAAC,eAAe,CACtB;YACE,EAAE,EAAE,kCAAe,CAAC,MAAM,CAAC,EAAE;YAC7B,KAAK,EAAE,IAAA,2BAAQ,EAAC,eAAe,CAAC;SACjC,EACD;YACE,OAAO,EAAE,GAAG,EAAE;gBACZ,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,CAAC;gBAChD,kBAAkB;gBAClB,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC;YACvD,CAAC;SACF,CACF,CAAC;IACJ,CAAC;IAED,mBAAmB,CAAC,QAA4B;QAC9C,QAAQ,CAAC,kBAAkB,CAAC;YAC1B,OAAO,EAAE,kCAAe,CAAC,MAAM,CAAC,EAAE;YAClC,UAAU,EAAE,OAAO;YACnB,IAAI,EAAE,GAAG,iCAAwB,CAAC,GAAG,EAAE;SACxC,CAAC,CAAC;IACL,CAAC;CACF,CAAA;AA1BC;IAAC,IAAA,cAAS,EAAC,uBAAc,CAAC;;yDACY;AAF3B,kBAAkB;IAD9B,IAAA,yBAAM,EAAC,sCAAmB,EAAE,yCAAsB,CAAC;GACvC,kBAAkB,CA2B9B;AA3BY,gDAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dialog.service.js","sourceRoot":"","sources":["../../src/browser/dialog.service.ts"],"names":[],"mappings":";;;;;AAAA,+BAA0C;AAE1C,qCAAqD;AACrD,+DAAkE;AAElE,sCAAyE;AAEzE,2DAAuD;
|
|
1
|
+
{"version":3,"file":"dialog.service.js","sourceRoot":"","sources":["../../src/browser/dialog.service.ts"],"names":[],"mappings":";;;;;AAAA,+BAA0C;AAE1C,qCAAqD;AACrD,+DAAkE;AAElE,sCAAyE;AAEzE,2DAAuD;AAGhD,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,+BAAsB;IAAlD;;QASK,YAAO,GAAG,KAAK,CAAC;QAEhB,YAAO,GAA6B,EAAE,CAAC;QAEvC,UAAK,GAAG,EAAE,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OAAO,CAAC;IACtB,CAAC;IAED,OAAO;QACL,OAAO,IAAI,CAAC,IAAI,CAAC;IACnB,CAAC;IAED,OAAO;QACL,QAAQ,IAAI,CAAC,IAAI,EAAE;YACjB,KAAK,6BAAW,CAAC,KAAK;gBACpB,OAAO;oBACL,KAAK,EAAE,0CAA0C;oBACjD,SAAS,EAAE,cAAc;iBAC1B,CAAC;YACJ,KAAK,6BAAW,CAAC,IAAI;gBACnB,OAAO;oBACL,KAAK,EAAE,yCAAyC;oBAChD,SAAS,EAAE,aAAa;iBACzB,CAAC;YACJ,KAAK,6BAAW,CAAC,OAAO;gBACtB,OAAO;oBACL,KAAK,EAAE,4CAA4C;oBACnD,SAAS,EAAE,iBAAiB;iBAC7B,CAAC;YACJ;gBACE,MAAM;SACT;IACH,CAAC;IAED,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;CACF,CAAA;AA9FC;IAAC,IAAA,cAAS,EAAC,oCAAgB,CAAC;sCACQ,oCAAgB;wDAAC;AAErD;IAAC,iBAAU;;8CACe;AAY1B;IAAC,aAAM;;;;yCAoBN;AAED;IAAC,aAAM;;iEACkB,CAAC,oBAAD,CAAC;;yCAIzB;AAED;IAAC,aAAM;;;;0CAMN;AAxDU,aAAa;IADzB,IAAA,eAAU,GAAE;GACA,aAAa,CAmGzB;AAnGY,sCAAa"}
|
package/lib/browser/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,iEAA2D;AAC3D,+FAAoG;AAEpG,sCAA4D;AAE5D,kEAAoE;AACpE,2DAAuD;AACvD,+DAA2D;AAC3D,qDAAiD;AACjD,6CAAuC;AACvC,uDAAmD;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/browser/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,iEAA2D;AAC3D,+FAAoG;AAEpG,sCAA4D;AAE5D,kEAAoE;AACpE,2DAAuD;AACvD,+DAA2D;AAC3D,qDAAiD;AACjD,6CAAuC;AACvC,uDAAmD;AAG5C,IAAM,aAAa,GAAnB,MAAM,aAAc,SAAQ,gCAAa;IAAzC;;QACL,cAAS,GAAe;YACtB;gBACE,KAAK,EAAE,oCAAgB;gBACvB,QAAQ,EAAE,oCAAgB;aAC3B;YACD;gBACE,KAAK,EAAE,uBAAc;gBACrB,QAAQ,EAAE,8BAAa;aACxB;YACD;gBACE,KAAK,EAAE,wBAAe;gBACtB,QAAQ,EAAE,gCAAc;aACzB;YACD;gBACE,KAAK,EAAE,yBAAe;gBACtB,QAAQ,EAAE,wCAAqB;aAChC;YACD,wCAAkB;SACnB,CAAC;QAEF,cAAS,GAAG,IAAI,CAAC;QACjB,cAAS,GAAG,oBAAO,CAAC;IACtB,CAAC;CAAA,CAAA;AAvBY,aAAa;IADzB,IAAA,eAAU,GAAE;GACA,aAAa,CAuBzB;AAvBY,sCAAa"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message.service.js","sourceRoot":"","sources":["../../src/browser/message.service.tsx"],"names":[],"mappings":";;;;;AAEA,qCAAqD;AACrD,6DAA8D;AAC9D,iEAAwE;AACxE,+DAAwE;AAExE,sCAAwF;
|
|
1
|
+
{"version":3,"file":"message.service.js","sourceRoot":"","sources":["../../src/browser/message.service.tsx"],"names":[],"mappings":";;;;;AAEA,qCAAqD;AACrD,6DAA8D;AAC9D,iEAAwE;AACxE,+DAAwE;AAExE,sCAAwF;AAGjF,IAAM,cAAc,sBAApB,MAAM,cAAe,SAAQ,+BAAsB;IAAnD;;QAOL,YAAY;QACJ,aAAQ,GAAG,CAAC,CAAC;IA8DvB,CAAC;IAjDC;;;;;;;OAOG;IACH,IAAI,CACF,UAAoC,EACpC,IAAiB,EACjB,OAAkB,EAClB,QA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CAAC,OAAO,EAAE,CAAC;IACzB,CAAC;;AA3DD,cAAc;AACd,0EAA0E;AACzD,oCAAqB,GAAG,EAAE,CAAC;AAE5C,4BAA4B;AACX,uBAAQ,GAA+B;IACtD,CAAC,6BAAW,CAAC,IAAI,CAAC,EAAE,EAAE;IACtB,CAAC,6BAAW,CAAC,OAAO,CAAC,EAAE,EAAE;IACzB,CAAC,6BAAW,CAAC,KAAK,CAAC,EAAE,EAAE;CACxB,CAAC;AAlBF;IAAC,IAAA,cAAS,EAAC,iCAAc,CAAC;;qDACqB;AAFpC,cAAc;IAD1B,IAAA,eAAU,GAAE;GACA,cAAc,CAsE1B;AAtEY,wCAAc"}
|
package/package.json
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-overlay",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"files": [
|
|
5
|
-
"lib"
|
|
5
|
+
"lib",
|
|
6
|
+
"src"
|
|
6
7
|
],
|
|
7
8
|
"license": "MIT",
|
|
8
9
|
"main": "lib/index.js",
|
|
9
10
|
"typings": "lib/index.d.ts",
|
|
10
11
|
"scripts": {
|
|
11
|
-
"prepublishOnly": "
|
|
12
|
+
"prepublishOnly": "yarn run build",
|
|
12
13
|
"build": "tsc --build ../../configs/ts/references/tsconfig.overlay.json"
|
|
13
14
|
},
|
|
14
15
|
"repository": {
|
|
@@ -16,12 +17,12 @@
|
|
|
16
17
|
"url": "git@github.com:opensumi/core.git"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@opensumi/ide-core-common": "2.
|
|
20
|
+
"@opensumi/ide-core-common": "2.22.0"
|
|
20
21
|
},
|
|
21
22
|
"devDependencies": {
|
|
22
|
-
"@opensumi/ide-components": "2.
|
|
23
|
-
"@opensumi/ide-core-browser": "2.
|
|
24
|
-
"@opensumi/ide-dev-tool": "
|
|
23
|
+
"@opensumi/ide-components": "2.22.0",
|
|
24
|
+
"@opensumi/ide-core-browser": "2.22.0",
|
|
25
|
+
"@opensumi/ide-dev-tool": "1.3.1"
|
|
25
26
|
},
|
|
26
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "927717e1c60f9cf5f01622fd51085b318a175eeb"
|
|
27
28
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { observable, action } from 'mobx';
|
|
2
|
+
|
|
3
|
+
import { Injectable } from '@opensumi/di';
|
|
4
|
+
import { MenuNode } from '@opensumi/ide-core-browser/lib/menu/next/base';
|
|
5
|
+
import { CtxMenuRenderParams } from '@opensumi/ide-core-browser/lib/menu/next/renderer/ctxmenu/base';
|
|
6
|
+
import { IBrowserCtxMenu } from '@opensumi/ide-core-browser/lib/menu/next/renderer/ctxmenu/browser';
|
|
7
|
+
|
|
8
|
+
@Injectable()
|
|
9
|
+
export class BrowserCtxMenuService implements IBrowserCtxMenu {
|
|
10
|
+
@observable
|
|
11
|
+
visible = false;
|
|
12
|
+
|
|
13
|
+
@observable
|
|
14
|
+
onHide: ((canceled: boolean) => void) | undefined = undefined;
|
|
15
|
+
|
|
16
|
+
@observable
|
|
17
|
+
point: { pageX: number; pageY: number } | undefined = undefined;
|
|
18
|
+
|
|
19
|
+
@observable
|
|
20
|
+
context: any = undefined;
|
|
21
|
+
|
|
22
|
+
@observable
|
|
23
|
+
menuNodes: MenuNode[] = observable.array([]);
|
|
24
|
+
|
|
25
|
+
@action
|
|
26
|
+
public show(payload: CtxMenuRenderParams): void {
|
|
27
|
+
const { anchor, onHide, args: context, menuNodes } = payload;
|
|
28
|
+
// 上层调用前已经将 MenuNodes 处理为数组了
|
|
29
|
+
if (!Array.isArray(menuNodes) || !menuNodes.length) {
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
this.context = context;
|
|
34
|
+
this.menuNodes.splice(0, this.menuNodes.length, ...menuNodes);
|
|
35
|
+
const { x, y } = anchor instanceof window.MouseEvent ? { x: anchor.clientX, y: anchor.clientY } : anchor;
|
|
36
|
+
this.onHide = onHide;
|
|
37
|
+
this.point = { pageX: x, pageY: y };
|
|
38
|
+
this.visible = true;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@action.bound
|
|
42
|
+
public hide(canceled: boolean) {
|
|
43
|
+
if (typeof this.onHide === 'function') {
|
|
44
|
+
this.onHide(canceled);
|
|
45
|
+
}
|
|
46
|
+
this.reset();
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
@action.bound
|
|
50
|
+
private reset() {
|
|
51
|
+
this.visible = false;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { observer } from 'mobx-react-lite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import CtxMenuTrigger from 'react-ctxmenu-trigger';
|
|
4
|
+
|
|
5
|
+
import { ClickOutside } from '@opensumi/ide-components';
|
|
6
|
+
import { useInjectable } from '@opensumi/ide-core-browser';
|
|
7
|
+
import { MenuActionList } from '@opensumi/ide-core-browser/lib/components/actions';
|
|
8
|
+
import placements from '@opensumi/ide-core-browser/lib/components/actions/placements';
|
|
9
|
+
import { IBrowserCtxMenu } from '@opensumi/ide-core-browser/lib/menu/next/renderer/ctxmenu/browser';
|
|
10
|
+
|
|
11
|
+
import 'react-ctxmenu-trigger/assets/index.css';
|
|
12
|
+
|
|
13
|
+
export const CtxMenu = observer(() => {
|
|
14
|
+
const ctxMenuService = useInjectable<IBrowserCtxMenu>(IBrowserCtxMenu);
|
|
15
|
+
|
|
16
|
+
const handleClick = React.useCallback(() => {
|
|
17
|
+
ctxMenuService.hide(false);
|
|
18
|
+
}, []);
|
|
19
|
+
|
|
20
|
+
const onClickOutSide = React.useCallback(() => {
|
|
21
|
+
if (ctxMenuService.visible) {
|
|
22
|
+
ctxMenuService.hide(true);
|
|
23
|
+
}
|
|
24
|
+
}, [ctxMenuService.visible]);
|
|
25
|
+
|
|
26
|
+
// todo: 缓存上一次点击 visible 完成 toggle 效果
|
|
27
|
+
return (
|
|
28
|
+
<CtxMenuTrigger
|
|
29
|
+
// popupTransitionName='slide-up'
|
|
30
|
+
popupPlacement='bottomLeft'
|
|
31
|
+
popupVisible={ctxMenuService.visible}
|
|
32
|
+
action={['contextMenu']}
|
|
33
|
+
popupAlign={{
|
|
34
|
+
overflow: {
|
|
35
|
+
adjustX: 1,
|
|
36
|
+
adjustY: 1,
|
|
37
|
+
},
|
|
38
|
+
offset: [window.scrollX, window.scrollY],
|
|
39
|
+
}}
|
|
40
|
+
point={ctxMenuService.point || {}}
|
|
41
|
+
popupClassName='point-popup'
|
|
42
|
+
builtinPlacements={placements}
|
|
43
|
+
popup={
|
|
44
|
+
<ClickOutside mouseEvents={['click', 'contextmenu']} onOutsideClick={onClickOutSide}>
|
|
45
|
+
<MenuActionList data={ctxMenuService.menuNodes} afterClick={handleClick} context={ctxMenuService.context} />
|
|
46
|
+
</ClickOutside>
|
|
47
|
+
}
|
|
48
|
+
alignPoint
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
CtxMenu.displayName = 'CtxMenu';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
2
|
+
import { IContextKeyService, IContextKey } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { DialogViewVisibleContext } from '@opensumi/ide-core-browser/lib/contextkey/dialog';
|
|
4
|
+
|
|
5
|
+
@Injectable()
|
|
6
|
+
export class DialogContextKey {
|
|
7
|
+
@Autowired(IContextKeyService)
|
|
8
|
+
private readonly globalContextKeyService: IContextKeyService;
|
|
9
|
+
|
|
10
|
+
public readonly dialogViewVisibleContext: IContextKey<boolean>;
|
|
11
|
+
|
|
12
|
+
private readonly _contextKeyService: IContextKeyService;
|
|
13
|
+
|
|
14
|
+
constructor() {
|
|
15
|
+
this._contextKeyService = this.globalContextKeyService;
|
|
16
|
+
this.dialogViewVisibleContext = DialogViewVisibleContext.bind(this._contextKeyService);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Autowired } from '@opensumi/di';
|
|
2
|
+
import {
|
|
3
|
+
DIALOG_COMMANDS,
|
|
4
|
+
Domain,
|
|
5
|
+
localize,
|
|
6
|
+
CommandContribution,
|
|
7
|
+
CommandRegistry,
|
|
8
|
+
KeybindingContribution,
|
|
9
|
+
KeybindingRegistry,
|
|
10
|
+
} from '@opensumi/ide-core-browser';
|
|
11
|
+
import { DialogViewVisibleContext } from '@opensumi/ide-core-browser/lib/contextkey/dialog';
|
|
12
|
+
|
|
13
|
+
import { IDialogService } from '../common';
|
|
14
|
+
|
|
15
|
+
@Domain(CommandContribution, KeybindingContribution)
|
|
16
|
+
export class DialogContribution implements CommandContribution, KeybindingContribution {
|
|
17
|
+
@Autowired(IDialogService)
|
|
18
|
+
private dialogService: IDialogService;
|
|
19
|
+
|
|
20
|
+
registerCommands(registry: CommandRegistry) {
|
|
21
|
+
registry.registerCommand(
|
|
22
|
+
{
|
|
23
|
+
id: DIALOG_COMMANDS.ENSURE.id,
|
|
24
|
+
label: localize('dialog.ensure'),
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
execute: () => {
|
|
28
|
+
const buttons = this.dialogService.getButtons();
|
|
29
|
+
// 默认使用最后一个选项作为返回值
|
|
30
|
+
this.dialogService.hide(buttons[buttons.length - 1]);
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
registerKeybindings(bindings: KeybindingRegistry) {
|
|
37
|
+
bindings.registerKeybinding({
|
|
38
|
+
command: DIALOG_COMMANDS.ENSURE.id,
|
|
39
|
+
keybinding: 'enter',
|
|
40
|
+
when: `${DialogViewVisibleContext.raw}`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { observable, action } from 'mobx';
|
|
2
|
+
|
|
3
|
+
import { Injectable, Autowired } from '@opensumi/di';
|
|
4
|
+
import { Deferred, MessageType } from '@opensumi/ide-core-common';
|
|
5
|
+
|
|
6
|
+
import { IDialogService, AbstractMessageService, Icon } from '../common';
|
|
7
|
+
|
|
8
|
+
import { DialogContextKey } from './dialog.contextkey';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class DialogService extends AbstractMessageService implements IDialogService {
|
|
12
|
+
protected type: MessageType | undefined;
|
|
13
|
+
|
|
14
|
+
protected deferred: Deferred<any>;
|
|
15
|
+
|
|
16
|
+
@Autowired(DialogContextKey)
|
|
17
|
+
private readonly contextkeyService: DialogContextKey;
|
|
18
|
+
|
|
19
|
+
@observable
|
|
20
|
+
protected visible = false;
|
|
21
|
+
|
|
22
|
+
protected message: string | React.ReactNode = '';
|
|
23
|
+
|
|
24
|
+
protected title = '';
|
|
25
|
+
|
|
26
|
+
public closable = true;
|
|
27
|
+
|
|
28
|
+
protected buttons: string[] = [];
|
|
29
|
+
|
|
30
|
+
protected props: Record<string, any> = {};
|
|
31
|
+
|
|
32
|
+
@action
|
|
33
|
+
open<T = string>(
|
|
34
|
+
message: string | React.ReactNode,
|
|
35
|
+
type: MessageType,
|
|
36
|
+
buttons?: any[],
|
|
37
|
+
closable = true,
|
|
38
|
+
_?: string,
|
|
39
|
+
props?: Record<string, any>,
|
|
40
|
+
): Promise<T | undefined> {
|
|
41
|
+
this.deferred = new Deferred<string>();
|
|
42
|
+
this.type = type;
|
|
43
|
+
this.message = message;
|
|
44
|
+
this.visible = true;
|
|
45
|
+
this.contextkeyService.dialogViewVisibleContext.set(true);
|
|
46
|
+
this.closable = closable;
|
|
47
|
+
this.props = props ?? {};
|
|
48
|
+
if (buttons) {
|
|
49
|
+
this.buttons = buttons;
|
|
50
|
+
}
|
|
51
|
+
return this.deferred.promise;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
@action
|
|
55
|
+
hide<T = string>(value?: T): void {
|
|
56
|
+
this.visible = false;
|
|
57
|
+
this.contextkeyService.dialogViewVisibleContext.set(false);
|
|
58
|
+
this.deferred.resolve(value);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@action
|
|
62
|
+
reset(): void {
|
|
63
|
+
this.type = undefined;
|
|
64
|
+
this.message = '';
|
|
65
|
+
this.buttons = [];
|
|
66
|
+
this.props = {};
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
isVisible(): boolean {
|
|
70
|
+
return this.visible;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
getMessage(): string | React.ReactNode {
|
|
74
|
+
return this.message;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
getType(): MessageType | undefined {
|
|
78
|
+
return this.type;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
getIcon(): Icon | undefined {
|
|
82
|
+
switch (this.type) {
|
|
83
|
+
case MessageType.Error:
|
|
84
|
+
return {
|
|
85
|
+
color: 'var(--notificationsErrorIcon-foreground)',
|
|
86
|
+
className: 'close-circle',
|
|
87
|
+
};
|
|
88
|
+
case MessageType.Info:
|
|
89
|
+
return {
|
|
90
|
+
color: 'var(--notificationsInfoIcon-foreground)',
|
|
91
|
+
className: 'info-circle',
|
|
92
|
+
};
|
|
93
|
+
case MessageType.Warning:
|
|
94
|
+
return {
|
|
95
|
+
color: 'var(--notificationsWarningIcon-foreground)',
|
|
96
|
+
className: 'question-circle',
|
|
97
|
+
};
|
|
98
|
+
default:
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
getButtons(): string[] {
|
|
104
|
+
return this.buttons;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
getProps(): Record<string, any> {
|
|
108
|
+
return this.props;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { observer } from 'mobx-react-lite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import { Button, Dialog as DialogView } from '@opensumi/ide-components';
|
|
5
|
+
import { useInjectable, localize } from '@opensumi/ide-core-browser';
|
|
6
|
+
import { strings } from '@opensumi/ide-core-browser';
|
|
7
|
+
|
|
8
|
+
import { IDialogService } from '../common';
|
|
9
|
+
|
|
10
|
+
export const Dialog = observer(() => {
|
|
11
|
+
const dialogService = useInjectable<IDialogService>(IDialogService);
|
|
12
|
+
const icon = dialogService.getIcon();
|
|
13
|
+
const message = dialogService.getMessage();
|
|
14
|
+
const buttons = dialogService.getButtons();
|
|
15
|
+
const type = dialogService.getType();
|
|
16
|
+
// props will transfer to Overlay component
|
|
17
|
+
const customProps = dialogService.getProps();
|
|
18
|
+
|
|
19
|
+
function afterClose() {
|
|
20
|
+
dialogService.reset();
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function handleClose() {
|
|
24
|
+
dialogService.hide();
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function handlerClickButton(value: string) {
|
|
28
|
+
return () => {
|
|
29
|
+
dialogService.hide(value);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (
|
|
34
|
+
<DialogView
|
|
35
|
+
visible={dialogService.isVisible()}
|
|
36
|
+
onClose={handleClose}
|
|
37
|
+
closable={dialogService.closable}
|
|
38
|
+
afterClose={afterClose}
|
|
39
|
+
message={message}
|
|
40
|
+
type='confirm'
|
|
41
|
+
messageType={type}
|
|
42
|
+
icon={icon}
|
|
43
|
+
keyboard={true}
|
|
44
|
+
buttons={
|
|
45
|
+
buttons.length ? (
|
|
46
|
+
buttons.map((button, index) => (
|
|
47
|
+
<Button
|
|
48
|
+
size='large'
|
|
49
|
+
onClick={handlerClickButton(button)}
|
|
50
|
+
key={button}
|
|
51
|
+
type={index === buttons.length - 1 ? 'primary' : 'secondary'}
|
|
52
|
+
>
|
|
53
|
+
{strings.mnemonicButtonLabel(button, true)}
|
|
54
|
+
</Button>
|
|
55
|
+
))
|
|
56
|
+
) : (
|
|
57
|
+
<Button size='large' onClick={handleClose} type='primary'>
|
|
58
|
+
{localize('dialog.confirm')}
|
|
59
|
+
</Button>
|
|
60
|
+
)
|
|
61
|
+
}
|
|
62
|
+
{...customProps}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
});
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Provider, Injectable } from '@opensumi/di';
|
|
2
|
+
import { BrowserModule } from '@opensumi/ide-core-browser';
|
|
3
|
+
import { IBrowserCtxMenu } from '@opensumi/ide-core-browser/lib/menu/next/renderer/ctxmenu/browser';
|
|
4
|
+
|
|
5
|
+
import { IDialogService, IMessageService } from '../common';
|
|
6
|
+
|
|
7
|
+
import { BrowserCtxMenuService } from './ctx-menu/ctx-menu.service';
|
|
8
|
+
import { DialogContextKey } from './dialog.contextkey';
|
|
9
|
+
import { DialogContribution } from './dialog.contribution';
|
|
10
|
+
import { DialogService } from './dialog.service';
|
|
11
|
+
import { Overlay } from './index.view';
|
|
12
|
+
import { MessageService } from './message.service';
|
|
13
|
+
|
|
14
|
+
@Injectable()
|
|
15
|
+
export class OverlayModule extends BrowserModule {
|
|
16
|
+
providers: Provider[] = [
|
|
17
|
+
{
|
|
18
|
+
token: DialogContextKey,
|
|
19
|
+
useClass: DialogContextKey,
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
token: IDialogService,
|
|
23
|
+
useClass: DialogService,
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
token: IMessageService,
|
|
27
|
+
useClass: MessageService,
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
token: IBrowserCtxMenu,
|
|
31
|
+
useClass: BrowserCtxMenuService,
|
|
32
|
+
},
|
|
33
|
+
DialogContribution,
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
isOverlay = true;
|
|
37
|
+
component = Overlay;
|
|
38
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { observer } from 'mobx-react-lite';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ComponentRenderer,
|
|
6
|
+
ComponentRegistry,
|
|
7
|
+
SlotLocation,
|
|
8
|
+
useInjectable,
|
|
9
|
+
AppConfig,
|
|
10
|
+
IClientApp,
|
|
11
|
+
} from '@opensumi/ide-core-browser';
|
|
12
|
+
|
|
13
|
+
import { CtxMenu } from './ctx-menu/ctx-menu.view';
|
|
14
|
+
import { Dialog } from './dialog.view';
|
|
15
|
+
import './styles.module.less';
|
|
16
|
+
|
|
17
|
+
export const Overlay = observer(() => {
|
|
18
|
+
const componentRegistry: ComponentRegistry = useInjectable(ComponentRegistry);
|
|
19
|
+
const clientApp = useInjectable(IClientApp);
|
|
20
|
+
const [extraComponents, setExtra] = React.useState<React.ComponentType[]>([]);
|
|
21
|
+
const appConfig: AppConfig = useInjectable(AppConfig);
|
|
22
|
+
React.useEffect(() => {
|
|
23
|
+
// 对于嵌套在模块视图的SlotRenderer,渲染时应用已启动
|
|
24
|
+
clientApp.appInitialized.promise.then(() => {
|
|
25
|
+
if (appConfig.layoutConfig[SlotLocation.extra]?.modules) {
|
|
26
|
+
const components: React.ComponentType[] = [];
|
|
27
|
+
appConfig.layoutConfig[SlotLocation.extra].modules.forEach((name) => {
|
|
28
|
+
const info = componentRegistry.getComponentRegistryInfo(name);
|
|
29
|
+
if (info) {
|
|
30
|
+
(info.views || []).forEach((v) => {
|
|
31
|
+
if (v.component) {
|
|
32
|
+
components.push(v.component!);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
setExtra(components);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}, []);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<div id='ide-overlay' className='ide-overlay'>
|
|
44
|
+
<Dialog />
|
|
45
|
+
<CtxMenu />
|
|
46
|
+
<ComponentRenderer Component={extraComponents} />
|
|
47
|
+
</div>
|
|
48
|
+
);
|
|
49
|
+
});
|
|
File without changes
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
4
|
+
import { notification, open } from '@opensumi/ide-components';
|
|
5
|
+
import { IOpenerService, toMarkdown } from '@opensumi/ide-core-browser';
|
|
6
|
+
import { MessageType, uuid, localize } from '@opensumi/ide-core-common';
|
|
7
|
+
|
|
8
|
+
import { IMessageService, AbstractMessageService, MAX_MESSAGE_LENGTH } from '../common';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class MessageService extends AbstractMessageService implements IMessageService {
|
|
12
|
+
@Autowired(IOpenerService)
|
|
13
|
+
private readonly openerService: IOpenerService;
|
|
14
|
+
|
|
15
|
+
// 上一个展示的文案
|
|
16
|
+
private preMessage: string | React.ReactNode;
|
|
17
|
+
|
|
18
|
+
// 当前组件展示的时间
|
|
19
|
+
private showTime = 0;
|
|
20
|
+
|
|
21
|
+
// 相同文案返回的间隔时间
|
|
22
|
+
// https://github.com/react-component/notification#notificationnoticeprops
|
|
23
|
+
protected static SAME_MESSAGE_DURATION = 30;
|
|
24
|
+
|
|
25
|
+
// 参考 vscode message 组件消失的时间
|
|
26
|
+
protected static DURATION: { [type: number]: number } = {
|
|
27
|
+
[MessageType.Info]: 15,
|
|
28
|
+
[MessageType.Warning]: 18,
|
|
29
|
+
[MessageType.Error]: 20,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
*
|
|
34
|
+
* @param rawMessage message
|
|
35
|
+
* @param type MessageType
|
|
36
|
+
* @param buttons buttons
|
|
37
|
+
* @param closable true | false
|
|
38
|
+
* @param from from extension
|
|
39
|
+
*/
|
|
40
|
+
open<T = string>(
|
|
41
|
+
rawMessage: string | React.ReactNode,
|
|
42
|
+
type: MessageType,
|
|
43
|
+
buttons?: string[],
|
|
44
|
+
closable = true,
|
|
45
|
+
from?: string,
|
|
46
|
+
): Promise<T | undefined> {
|
|
47
|
+
if (!rawMessage) {
|
|
48
|
+
return Promise.resolve(undefined);
|
|
49
|
+
}
|
|
50
|
+
let message = rawMessage;
|
|
51
|
+
// 如果两秒内提示信息相同,则直接返回上一个提示
|
|
52
|
+
if (
|
|
53
|
+
Date.now() - this.showTime < MessageService.SAME_MESSAGE_DURATION &&
|
|
54
|
+
typeof message === 'string' &&
|
|
55
|
+
this.preMessage === message
|
|
56
|
+
) {
|
|
57
|
+
return Promise.resolve(undefined);
|
|
58
|
+
}
|
|
59
|
+
this.preMessage = typeof message === 'string' && message;
|
|
60
|
+
this.showTime = Date.now();
|
|
61
|
+
if (typeof rawMessage === 'string' && rawMessage.length > MAX_MESSAGE_LENGTH) {
|
|
62
|
+
message = `${rawMessage.substr(0, MAX_MESSAGE_LENGTH)}...`;
|
|
63
|
+
}
|
|
64
|
+
const description = from && typeof from === 'string' ? `${localize('component.message.origin')}: ${from}` : '';
|
|
65
|
+
const key = uuid();
|
|
66
|
+
const promise = open<T>(
|
|
67
|
+
toMarkdown(message, this.openerService),
|
|
68
|
+
type,
|
|
69
|
+
closable,
|
|
70
|
+
key,
|
|
71
|
+
buttons,
|
|
72
|
+
description,
|
|
73
|
+
MessageService.DURATION[type],
|
|
74
|
+
);
|
|
75
|
+
return promise || Promise.resolve(undefined);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
hide(): void {
|
|
79
|
+
notification.destroy();
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { MessageType, URI } from '@opensumi/ide-core-common';
|
|
4
|
+
|
|
5
|
+
export const IMessageService = Symbol('IMessageService');
|
|
6
|
+
|
|
7
|
+
export interface IMessageService {
|
|
8
|
+
info(
|
|
9
|
+
message: string | React.ReactNode,
|
|
10
|
+
buttons?: string[],
|
|
11
|
+
closable?: boolean,
|
|
12
|
+
props?: Record<string, any>,
|
|
13
|
+
): Promise<string | undefined>;
|
|
14
|
+
warning(
|
|
15
|
+
message: string | React.ReactNode,
|
|
16
|
+
buttons?: string[],
|
|
17
|
+
closable?: boolean,
|
|
18
|
+
props?: Record<string, any>,
|
|
19
|
+
): Promise<string | undefined>;
|
|
20
|
+
error(
|
|
21
|
+
message: string | React.ReactNode,
|
|
22
|
+
buttons?: string[],
|
|
23
|
+
closable?: boolean,
|
|
24
|
+
props?: Record<string, any>,
|
|
25
|
+
): Promise<string | undefined>;
|
|
26
|
+
open<T = string>(
|
|
27
|
+
message: string | React.ReactNode,
|
|
28
|
+
type: MessageType,
|
|
29
|
+
buttons?: string[],
|
|
30
|
+
closable?: boolean,
|
|
31
|
+
from?: string,
|
|
32
|
+
props?: Record<string, any>,
|
|
33
|
+
): Promise<T | undefined>;
|
|
34
|
+
hide<T = string>(value?: T): void;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface Icon {
|
|
38
|
+
color: string;
|
|
39
|
+
className: string;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const MAX_MESSAGE_LENGTH = 1000;
|
|
43
|
+
|
|
44
|
+
export const IDialogService = Symbol('IDialogService');
|
|
45
|
+
export interface IDialogService extends IMessageService {
|
|
46
|
+
closable?: boolean;
|
|
47
|
+
isVisible(): boolean;
|
|
48
|
+
getMessage(): string | React.ReactNode;
|
|
49
|
+
getIcon(): Icon | undefined;
|
|
50
|
+
getButtons(): string[];
|
|
51
|
+
getType(): MessageType | undefined;
|
|
52
|
+
getProps(): Record<string, any>;
|
|
53
|
+
reset(): void;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export abstract class AbstractMessageService implements IMessageService {
|
|
57
|
+
info(
|
|
58
|
+
message: string | React.ReactNode,
|
|
59
|
+
buttons?: string[],
|
|
60
|
+
closable?: boolean,
|
|
61
|
+
props?: Record<string, any>,
|
|
62
|
+
): Promise<string | undefined> {
|
|
63
|
+
return this.open(message, MessageType.Info, buttons, closable, undefined, props);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
warning(
|
|
67
|
+
message: string | React.ReactNode,
|
|
68
|
+
buttons?: string[],
|
|
69
|
+
closable?: boolean,
|
|
70
|
+
props?: Record<string, any>,
|
|
71
|
+
): Promise<string | undefined> {
|
|
72
|
+
return this.open(message, MessageType.Warning, buttons, closable, undefined, props);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
error(
|
|
76
|
+
message: string | React.ReactNode,
|
|
77
|
+
buttons?: string[],
|
|
78
|
+
closable?: boolean,
|
|
79
|
+
props?: Record<string, any>,
|
|
80
|
+
): Promise<string | undefined> {
|
|
81
|
+
return this.open(message, MessageType.Error, buttons, closable, undefined, props);
|
|
82
|
+
}
|
|
83
|
+
abstract open<T = string>(
|
|
84
|
+
message: string | React.ReactNode,
|
|
85
|
+
type: MessageType,
|
|
86
|
+
buttons?: any[],
|
|
87
|
+
closable?: boolean,
|
|
88
|
+
from?: string,
|
|
89
|
+
props?: Record<string, any>,
|
|
90
|
+
): Promise<T | undefined>;
|
|
91
|
+
abstract hide<T = string>(value?: T): void;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface IWindowDialogService {
|
|
95
|
+
showOpenDialog(options?: IOpenDialogOptions): Promise<URI[] | undefined>;
|
|
96
|
+
showSaveDialog(options?: ISaveDialogOptions): Promise<URI | undefined>;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const IWindowDialogService = Symbol('IWindowDialogService');
|
|
100
|
+
|
|
101
|
+
export interface IDialogOptions {
|
|
102
|
+
title?: string;
|
|
103
|
+
defaultUri?: URI;
|
|
104
|
+
filters?: {
|
|
105
|
+
[name: string]: string;
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export interface ISaveDialogOptions extends IDialogOptions {
|
|
110
|
+
saveLabel?: string;
|
|
111
|
+
showNameInput?: boolean;
|
|
112
|
+
defaultFileName?: string;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface IOpenDialogOptions extends IDialogOptions {
|
|
116
|
+
canSelectFiles?: boolean;
|
|
117
|
+
canSelectFolders?: boolean;
|
|
118
|
+
canSelectMany?: boolean;
|
|
119
|
+
openLabel?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export namespace ISaveDialogOptions {
|
|
123
|
+
export function is(option) {
|
|
124
|
+
return 'saveLabel' in option || 'showNameInput' in option || 'defaultFileName' in option;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export namespace IOpenDialogOptions {
|
|
129
|
+
export function is(option) {
|
|
130
|
+
return (
|
|
131
|
+
'canSelectFiles' in option || 'canSelectFolders' in option || 'canSelectMany' in option || 'openLabel' in option
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './common';
|