Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions extensions/open-with-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion extensions/search-notion/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Search Notion pages and open visited ones faster. No admin access required.",
"icon": "command-icon.png",
"author": "reckoning-dev",
"version": "1.0.0",
"version": "1.1.0",
"license": "MIT",
"commands": [
{
Expand Down
39 changes: 35 additions & 4 deletions extensions/search-notion/src/common/View.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { ActionPanel, CopyToClipboardAction, List, OpenInBrowserAction, Icon } from "@raycast/api";
import {
ActionPanel,
CopyToClipboardAction,
List,
OpenInBrowserAction,
Icon,
OpenAction,
getApplications, Application
} from "@raycast/api";
import type { QueryResultItem } from "./notionApi";
import { useVisitedUrls } from "./useVisitedUrls";
import {useEffect, useState} from "react";


type Props = {
Expand All @@ -11,6 +20,28 @@ type Props = {
throttle?: boolean;
};

function OpenFileAction(props: { fileId: string, onOpen: (target: string) => void}) {
const [desktopApp, setDesktopApp] = useState<Application>()

useEffect(() => {
getApplications()
.then((apps) => apps.find((a) => a.bundleId === "notion.id"))
.then(setDesktopApp)
}, [])

return desktopApp ? (
<OpenAction
icon="command-icon.png"
title="Open in Notion"
target={`notion://file/${props.fileId}`}
application={desktopApp}
onOpen={() => props.onOpen(props.fileId)}
/>
) : (
<OpenInBrowserAction url={`https://www.notion.so/${props.fileId}`} onOpen={() => props.onOpen(props.fileId)}/>
)
}

export const View = ({ sectionNames, queryResults, isLoading, onSearchTextChange, throttle }: Props): JSX.Element => {
const [urls, onOpen] = useVisitedUrls();
return (
Expand All @@ -26,14 +57,14 @@ export const View = ({ sectionNames, queryResults, isLoading, onSearchTextChange
<List.Item
key={item.id}
id={item.id}
title={item.title + (urls.includes(item.url) ? " (visited)" : "")}
title={item.title + (urls.includes(item.fileId) ? " (visited)" : "")}
subtitle={item.subtitle}
icon={item.icon !== '' ? item.icon : Icon.Document}
accessoryTitle={item.accessoryTitle}
actions={
<ActionPanel>
<OpenInBrowserAction url={item.url} onOpen={onOpen} />
<CopyToClipboardAction title="Copy URL" content={item.url} />
<OpenFileAction fileId={item.fileId} onOpen={onOpen}/>
<CopyToClipboardAction title="Copy URL" content={`https://www.notion.so/${item.fileId}`} />
</ActionPanel>
}
/>
Expand Down
4 changes: 2 additions & 2 deletions extensions/search-notion/src/common/notionApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export type QueryResultItem = {
id: string;
title: string;
subtitle: string;
url: string;
fileId: string;
accessoryTitle: string;
icon: string;
};
Expand All @@ -32,7 +32,7 @@ const parseRepositoryItem = (data: any) => {
id: `${item.id}`,
title: `${reg_title}`,
subtitle: '',
url: `https://www.notion.so/`+ `${item.id}`.replace(/-/g, ''),
fileId: `${item.id}`.replace(/-/g, ''),
accessoryTitle: acc_title,
icon: page_icon,
};
Expand Down