mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-09 13:00:53 +01:00
copy to clipboard as keyboard command as well
This commit is contained in:
parent
2e4d3c3da7
commit
778d801b88
@ -31,8 +31,6 @@ function CodeRenderer(props : any) : any {
|
||||
|
||||
@mobxReact.observer
|
||||
class Bookmark extends React.Component<{bookmark : BookmarkType}, {}> {
|
||||
copiedIndicator : OV<boolean> = mobx.observable.box(false, {name: "copiedIndicator"});
|
||||
|
||||
@boundMethod
|
||||
handleDeleteClick() : void {
|
||||
let {bookmark} = this.props;
|
||||
@ -56,7 +54,7 @@ class Bookmark extends React.Component<{bookmark : BookmarkType}, {}> {
|
||||
|
||||
@boundMethod
|
||||
handleEditUpdate() : void {
|
||||
let model = GlobalModel.bookmarksModel;opie
|
||||
let model = GlobalModel.bookmarksModel;
|
||||
model.confirmEdit();
|
||||
return;
|
||||
}
|
||||
@ -93,16 +91,9 @@ class Bookmark extends React.Component<{bookmark : BookmarkType}, {}> {
|
||||
|
||||
@boundMethod
|
||||
clickCopy() : void {
|
||||
let bm = this.props.bookmark
|
||||
navigator.clipboard.writeText(bm.cmdstr);
|
||||
mobx.action(() => {
|
||||
this.copiedIndicator.set(true);
|
||||
})();
|
||||
setTimeout(() => {
|
||||
mobx.action(() => {
|
||||
this.copiedIndicator.set(false);
|
||||
})();
|
||||
}, 600)
|
||||
let bm = this.props.bookmark;
|
||||
let model = GlobalModel.bookmarksModel;
|
||||
model.handleCopyBookmark(bm.bookmarkid);
|
||||
}
|
||||
|
||||
render() {
|
||||
@ -122,6 +113,7 @@ class Bookmark extends React.Component<{bookmark : BookmarkType}, {}> {
|
||||
};
|
||||
let hasDesc = markdown != "";
|
||||
let isEditing = (model.editingBookmark.get() == bm.bookmarkid);
|
||||
let isCopied = mobx.computed(() => (model.copiedIndicator.get() == bm.bookmarkid)).get();
|
||||
if (isEditing) {
|
||||
return (
|
||||
<div data-bookmarkid={bm.bookmarkid} className={cn("bookmark focus-parent is-editing", {"pending-delete": model.pendingDelete.get() == bm.bookmarkid})}>
|
||||
@ -153,7 +145,7 @@ class Bookmark extends React.Component<{bookmark : BookmarkType}, {}> {
|
||||
}
|
||||
return (
|
||||
<div className={cn("bookmark focus-parent", {"pending-delete": model.pendingDelete.get() == bm.bookmarkid})} onClick={this.handleClick}>
|
||||
<If condition={this.copiedIndicator.get()}>
|
||||
<If condition={isCopied}>
|
||||
<div className="copied-indicator">
|
||||
<div>copied</div>
|
||||
</div>
|
||||
@ -225,6 +217,7 @@ class BookmarksView extends React.Component<{}, {}> {
|
||||
[Backspace/Delete]x2 or <i className="fa-sharp fa-solid fa-trash"/> to Delete<br/>
|
||||
[Arrow Up]/[Arrow Down]/[PageUp]/[PageDown] to Move in List<br/>
|
||||
[e] or <i className="fa-sharp fa-solid fa-pen"/> to Edit<br/>
|
||||
[c] or <i className="fa-sharp fa-regular fa-copy"/> to Copy<br/>
|
||||
</div>
|
||||
</div>
|
||||
</If>
|
||||
|
67
src/model.ts
67
src/model.ts
@ -690,6 +690,28 @@ class ScreenWindow {
|
||||
getWindow() : Window {
|
||||
return GlobalModel.getWindowById(this.sessionId, this.windowId);
|
||||
}
|
||||
|
||||
giveFocus() : void {
|
||||
if (!this.isActive()) {
|
||||
return;
|
||||
}
|
||||
let ftype = this.focusType.get();
|
||||
if (ftype == "input") {
|
||||
GlobalModel.inputModel.giveFocus();
|
||||
}
|
||||
else {
|
||||
let sline : LineType = null;
|
||||
if (this.selectedLine.get() != 0) {
|
||||
sline = this.getLineByNum(this.selectedLine.get());
|
||||
}
|
||||
if (sline != null) {
|
||||
let termWrap = this.getRenderer(sline.cmdid);
|
||||
if (termWrap != null) {
|
||||
termWrap.giveFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Window {
|
||||
@ -1784,9 +1806,8 @@ class HistoryViewModel {
|
||||
}
|
||||
|
||||
closeView() : void {
|
||||
mobx.action(() => {
|
||||
GlobalModel.activeMainView.set("session");
|
||||
})();
|
||||
GlobalModel.showSessionView();
|
||||
setTimeout(() => GlobalModel.inputModel.giveFocus(), 50);
|
||||
}
|
||||
|
||||
getLineById(lineId : string) : LineType {
|
||||
@ -1886,7 +1907,7 @@ class HistoryViewModel {
|
||||
|
||||
_getSearchParams(newOffset? : number) : HistorySearchParams {
|
||||
let offset = (newOffset != null ? newOffset : this.offset.get());
|
||||
let opts : HistorySearchParms = {
|
||||
let opts : HistorySearchParams = {
|
||||
offset: offset,
|
||||
searchText: this.activeSearchText,
|
||||
searchSessionId: this.searchSessionId.get(),
|
||||
@ -1980,6 +2001,7 @@ class BookmarksModel {
|
||||
activeBookmark : OV<string> = mobx.observable.box(null, {name: "activeBookmark"});
|
||||
editingBookmark : OV<string> = mobx.observable.box(null, {name: "editingBookmark"});
|
||||
pendingDelete : OV<string> = mobx.observable.box(null, {name: "pendingDelete"});
|
||||
copiedIndicator : OV<string> = mobx.observable.box(null, {name: "copiedIndicator"});
|
||||
|
||||
tempDesc : OV<string> = mobx.observable.box("", {name: "bookmarkEdit-tempDesc"});
|
||||
tempCmd : OV<string> = mobx.observable.box("", {name: "bookmarkEdit-tempCmd"});
|
||||
@ -2008,9 +2030,8 @@ class BookmarksModel {
|
||||
}
|
||||
|
||||
closeView() : void {
|
||||
mobx.action(() => {
|
||||
GlobalModel.activeMainView.set("session");
|
||||
})();
|
||||
GlobalModel.showSessionView();
|
||||
setTimeout(() => GlobalModel.inputModel.giveFocus(), 50);
|
||||
}
|
||||
|
||||
@boundMethod
|
||||
@ -2025,7 +2046,7 @@ class BookmarksModel {
|
||||
}
|
||||
mobx.action(() => {
|
||||
this.reset();
|
||||
GlobalModel.activeMainView.set("session");
|
||||
GlobalModel.showSessionView();
|
||||
GlobalModel.inputModel.setCurLine(bm.cmdstr);
|
||||
setTimeout(() => GlobalModel.inputModel.giveFocus(), 50);
|
||||
})();
|
||||
@ -2124,6 +2145,22 @@ class BookmarksModel {
|
||||
})();
|
||||
}
|
||||
|
||||
handleCopyBookmark(bookmarkId : string) : void {
|
||||
let bm = this.getBookmark(bookmarkId);
|
||||
if (bm == null) {
|
||||
return;
|
||||
}
|
||||
navigator.clipboard.writeText(bm.cmdstr);
|
||||
mobx.action(() => {
|
||||
this.copiedIndicator.set(bm.bookmarkid);
|
||||
})();
|
||||
setTimeout(() => {
|
||||
mobx.action(() => {
|
||||
this.copiedIndicator.set(null);
|
||||
})();
|
||||
}, 600)
|
||||
}
|
||||
|
||||
mergeBookmarks(bmArr : BookmarkType[]) : void {
|
||||
mobx.action(() => {
|
||||
genMergeSimpleData(this.bookmarks, bmArr, (bm : BookmarkType) => bm.bookmarkid, (bm : BookmarkType) => sprintf("%05d", bm.orderidx));
|
||||
@ -2190,6 +2227,14 @@ class BookmarksModel {
|
||||
this.handleEditBookmark(this.activeBookmark.get());
|
||||
return;
|
||||
}
|
||||
if (e.code == "KeyC") {
|
||||
if (this.activeBookmark.get() == null) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
this.handleCopyBookmark(this.activeBookmark.get());
|
||||
return;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -2290,6 +2335,12 @@ class Model {
|
||||
}
|
||||
}
|
||||
|
||||
showSessionView() : void {
|
||||
mobx.action(() => {
|
||||
this.activeMainView.set("session");
|
||||
})();
|
||||
}
|
||||
|
||||
getBaseHostPort() : string {
|
||||
if (this.isDev) {
|
||||
return DevServerEndpoint;
|
||||
|
@ -134,9 +134,9 @@ type FeStateType = {
|
||||
};
|
||||
|
||||
type RemotePtrType = {
|
||||
ownerid : string,
|
||||
remoteid : string,
|
||||
name : string,
|
||||
ownerid? : string,
|
||||
name? : string,
|
||||
};
|
||||
|
||||
type WindowDataType = {
|
||||
@ -432,7 +432,7 @@ type HistorySearchParams = {
|
||||
searchText? : string,
|
||||
searchSessionId? : string,
|
||||
searchRemoteId? : string,
|
||||
fromts? : number,
|
||||
fromTs? : number,
|
||||
noMeta? : boolean,
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user