diff --git a/.changeset/open-file-intellij.md b/.changeset/open-file-intellij.md
new file mode 100644
index 0000000..6d8973f
--- /dev/null
+++ b/.changeset/open-file-intellij.md
@@ -0,0 +1,5 @@
+---
+"click-to-react-component": patch
+---
+
+Added Support for OpenFile to Intellij
diff --git a/.gitignore b/.gitignore
index 30293be..28acec4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -105,3 +105,4 @@ dist
# TernJS port file
.tern-port
+/.idea/
diff --git a/packages/click-to-react-component/README.md b/packages/click-to-react-component/README.md
index 4215219..3499a1c 100644
--- a/packages/click-to-react-component/README.md
+++ b/packages/click-to-react-component/README.md
@@ -138,6 +138,13 @@ If, like me, you use [`vscode-insiders`](https://code.visualstudio.com/insiders/
+
```
+If, you use [`intellij`], you can set `editor` explicitly:
+
+```diff
+-
++
+```
+
## Run Locally
Clone the project
diff --git a/packages/click-to-react-component/src/ClickToComponent.js b/packages/click-to-react-component/src/ClickToComponent.js
index 4bc8404..bfa2741 100644
--- a/packages/click-to-react-component/src/ClickToComponent.js
+++ b/packages/click-to-react-component/src/ClickToComponent.js
@@ -41,11 +41,8 @@ export function ClickToComponent({ editor = 'vscode' }) {
if (state === State.HOVER && target instanceof HTMLElement) {
const source = getSourceForElement(target)
const path = getPathToSource(source)
- const url = `${editor}://file/${path}`
-
event.preventDefault()
- window.open(url)
-
+ openFileInIDE(path)
setState(State.IDLE)
}
},
@@ -55,15 +52,26 @@ export function ClickToComponent({ editor = 'vscode' }) {
const onClose = React.useCallback(
function handleClose(returnValue) {
if (returnValue) {
- const url = `${editor}://file/${returnValue}`
- window.open(url)
+ openFileInIDE(returnValue)
}
-
setState(State.IDLE)
},
[editor]
)
+ const openFileInIDE = (file) => {
+ if (editor === 'intellij') {
+ const url = `http://localhost:63342/api/file/${file}`
+ const cmd = window.open(url)
+ setTimeout(function() {
+ cmd.close();
+ }, 100);
+ } else {
+ const url = `${editor}://file/${file}`
+ window.open(url)
+ }
+ }
+
const onContextMenu = React.useCallback(
function handleContextMenu(
/**
diff --git a/packages/click-to-react-component/src/types.d.ts b/packages/click-to-react-component/src/types.d.ts
index d48a719..6f10ee7 100644
--- a/packages/click-to-react-component/src/types.d.ts
+++ b/packages/click-to-react-component/src/types.d.ts
@@ -1,6 +1,6 @@
export { ClickToComponent } from './src/ClickToComponent'
-export type Editor = 'vscode' | 'vscode-insiders'
+export type Editor = 'vscode' | 'vscode-insiders' | 'intellij'
export type ClickToComponentProps = {
editor?: Editor