зеркало из https://github.com/electron/electron.git
feat: emit `devtools-open-url` event for DevTools link selection (#36774)
* feat: emit event for DevTools link selection * chore: devtools-open-in-new-tab -> devtools-open-url
This commit is contained in:
Родитель
8d008c977d
Коммит
7d46d3ec9d
|
@ -492,6 +492,14 @@ The `focus` and `blur` events of `WebContents` should only be used to detect
|
|||
focus change between different `WebContents` and `BrowserView` in the same
|
||||
window.
|
||||
|
||||
#### Event: 'devtools-open-url'
|
||||
|
||||
Returns:
|
||||
|
||||
* `url` string - URL of the link that was clicked or selected.
|
||||
|
||||
Emitted when a link is clicked in DevTools or 'Open in new tab' is selected for a link in its context menu.
|
||||
|
||||
#### Event: 'devtools-opened'
|
||||
|
||||
Emitted when DevTools is opened.
|
||||
|
|
|
@ -981,6 +981,14 @@ Returns:
|
|||
|
||||
Emitted when mouse moves over a link or the keyboard moves the focus to a link.
|
||||
|
||||
### Event: 'devtools-open-url'
|
||||
|
||||
Returns:
|
||||
|
||||
* `url` string - URL of the link that was clicked or selected.
|
||||
|
||||
Emitted when a link is clicked in DevTools or 'Open in new tab' is selected for a link in its context menu.
|
||||
|
||||
### Event: 'devtools-opened'
|
||||
|
||||
Emitted when DevTools is opened.
|
||||
|
|
|
@ -9,6 +9,7 @@ export const webViewEvents: Record<string, readonly string[]> = {
|
|||
'dom-ready': [],
|
||||
'console-message': ['level', 'message', 'line', 'sourceId'],
|
||||
'context-menu': ['params'],
|
||||
'devtools-open-url': ['url'],
|
||||
'devtools-opened': [],
|
||||
'devtools-closed': [],
|
||||
'devtools-focused': [],
|
||||
|
|
|
@ -3825,6 +3825,10 @@ void WebContents::DevToolsStopIndexing(int request_id) {
|
|||
devtools_indexing_jobs_.erase(it);
|
||||
}
|
||||
|
||||
void WebContents::DevToolsOpenInNewTab(const std::string& url) {
|
||||
Emit("devtools-open-url", url);
|
||||
}
|
||||
|
||||
void WebContents::DevToolsSearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& query) {
|
||||
|
|
|
@ -704,6 +704,7 @@ class WebContents : public ExclusiveAccessContext,
|
|||
void DevToolsIndexPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& excluded_folders_message) override;
|
||||
void DevToolsOpenInNewTab(const std::string& url) override;
|
||||
void DevToolsStopIndexing(int request_id) override;
|
||||
void DevToolsSearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
|
|
|
@ -723,7 +723,10 @@ void InspectableWebContents::SetIsDocked(DispatchCallback callback,
|
|||
std::move(callback).Run(nullptr);
|
||||
}
|
||||
|
||||
void InspectableWebContents::OpenInNewTab(const std::string& url) {}
|
||||
void InspectableWebContents::OpenInNewTab(const std::string& url) {
|
||||
if (delegate_)
|
||||
delegate_->DevToolsOpenInNewTab(url);
|
||||
}
|
||||
|
||||
void InspectableWebContents::ShowItemInFolder(
|
||||
const std::string& file_system_path) {
|
||||
|
|
|
@ -31,6 +31,7 @@ class InspectableWebContentsDelegate {
|
|||
virtual void DevToolsIndexPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
const std::string& excluded_folders) {}
|
||||
virtual void DevToolsOpenInNewTab(const std::string& url) {}
|
||||
virtual void DevToolsStopIndexing(int request_id) {}
|
||||
virtual void DevToolsSearchInPath(int request_id,
|
||||
const std::string& file_system_path,
|
||||
|
|
Загрузка…
Ссылка в новой задаче