Skip to content

Commit

Permalink
Update bear extension (raycast#7449)
Browse files Browse the repository at this point in the history
* Update bear extension

- update: changelog
- fix: correcting my username as contributor
- feat: adding filter to search view and changing preview command from cmd+p to cmd+shift+p to follow raycast conventions

* Update extensions/bear/src/index.tsx

Update handle tag change

Co-authored-by: Harry Marr <hmarr@github.com>

* Update bear extension

- Merge branch 'contributions/merge-1684932175236717000'
- Pull contributions
- pushing not finished testing code to try the new filter functionality

* fix: implementing feedback on how the filter is supposed to work

* Update extensions/bear/src/db-queries.ts

Co-authored-by: Harry Marr <hmarr@github.com>

* Update extensions/bear/src/db-queries.ts

Co-authored-by: Harry Marr <hmarr@github.com>

* Update bear extension

- Merge branch 'contributions/merge-1688940908726919000'
- Pull contributions
- feat: adding new command options for create a new note and a new option in search to create a note when there is no note found

* fix: adding changelog

* Fix reading on Changelog

---------

Co-authored-by: Harry Marr <hmarr@github.com>
Co-authored-by: Milena Araujo <mil3na@users.noreply.github.com>
  • Loading branch information
3 people authored Jul 14, 2023
1 parent 9664ac8 commit 79ae43d
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 7 deletions.
5 changes: 5 additions & 0 deletions extensions/bear/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Bear Changelog

## [Create new note configurations and new search feature] - 2023-07-09

- When creating a new note, you can choose default options that you don't have to pick in the form. Options are: opening the note in the main window, in a new window, or don't open it at all.
- When searching notes, now if the query didn't match any note, you can create a new note with the query as the title.

## [Adding tag's filter in search notes] - 2023-05-23

- Adding tag's filter in search notes command
Expand Down
43 changes: 42 additions & 1 deletion extensions/bear/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,48 @@
"title": "Create Note",
"subtitle": "Bear",
"description": "Create a new bear note",
"mode": "view"
"mode": "view",
"preferences": [
{
"default": "main",
"description": "Choose default opening mode when creating a new note",
"label": "Open new notes in",
"name": "newNoteOpenMode",
"required": false,
"title": "Opening Notes",
"type": "dropdown",
"data": [
{
"title": "Don't Open Note",
"value": "no"
},
{
"title": "In Main Window",
"value": "main"
},
{
"title": "In New Window",
"value": "new"
}
]
},
{
"default": false,
"description": "When creating a new note, prepend time and date",
"label": "Prepend time and date",
"name": "prependTimeAndDate",
"required": false,
"type": "checkbox"
},
{
"default": false,
"description": "When creating a new note, prepend time and date",
"label": "Pin note in notes list",
"name": "pinNote",
"required": false,
"type": "checkbox"
}
]
},
{
"name": "grab-url",
Expand Down
19 changes: 17 additions & 2 deletions extensions/bear/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Color, getPreferenceValues, LaunchProps, List, showToast, Toast } from "@raycast/api";
import { Action, ActionPanel, Color, getPreferenceValues, LaunchProps, List, showToast, Toast } from "@raycast/api";
import { formatDistanceToNowStrict } from "date-fns";
import { useEffect, useState } from "react";
import { Note } from "./bear-db";
import { useBearDb } from "./hooks";
import NoteActions from "./note-actions";
import NoteActions, { createBasicNote } from "./note-actions";
import TagsDropdown from "./search-dropdown";

interface SearchNotesArguments {
Expand Down Expand Up @@ -65,6 +65,21 @@ export default function SearchNotes(props: LaunchProps<{ arguments: SearchNotesA
}
/>
))}
{notes?.length === 0 && (
<List.Item
title={searchQuery}
icon={{ source: "command-icon.png" }}
actions={
<ActionPanel>
<Action
title="Create new note"
shortcut={{ modifiers: ["cmd"], key: "n" }}
onAction={() => createBasicNote(searchQuery)}
/>
</ActionPanel>
}
/>
)}
</List>
);
}
Expand Down
19 changes: 15 additions & 4 deletions extensions/bear/src/new-note.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { ActionPanel, Action, closeMainWindow, Form, Icon, showToast, Toast, popToRoot } from "@raycast/api";
import {
ActionPanel,
Action,
closeMainWindow,
Form,
Icon,
showToast,
Toast,
popToRoot,
getPreferenceValues,
} from "@raycast/api";
import open from "open";

interface FormValues {
Expand Down Expand Up @@ -33,6 +43,7 @@ function CreateNoteAction() {
}

export default function NewNote() {
const { newNoteOpenMode, prependTimeAndDate, pinNote } = getPreferenceValues();
return (
<Form
navigationTitle={"Create Note"}
Expand All @@ -46,13 +57,13 @@ export default function NewNote() {
<Form.TextArea id="text" title="Text" placeholder="Text to add to note ..." />
<Form.TextField id="tags" title="Tags" placeholder="comma,separated,tags" />
<Form.Separator />
<Form.Dropdown id="openNote" title="Open Note">
<Form.Dropdown id="openNote" title="Open Note" defaultValue={newNoteOpenMode}>
<Form.Dropdown.Item value="no" title="Don't Open Note" />
<Form.Dropdown.Item value="main" title="In Main Window" />
<Form.Dropdown.Item value="new" title="In New Window" />
</Form.Dropdown>
<Form.Checkbox id="timestamp" label="Prepend time and date" />
<Form.Checkbox id="pin" label="Pin note in notes list" />
<Form.Checkbox id="timestamp" label="Prepend time and date" defaultValue={prependTimeAndDate} />
<Form.Checkbox id="pin" label="Pin note in notes list" defaultValue={pinNote} />
</Form>
);
}
6 changes: 6 additions & 0 deletions extensions/bear/src/note-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ function renderMarkdown(noteText: string): string {
}
}

export function createBasicNote(title: string) {
return open(`bear://x-callback-url/create?title=${encodeURIComponent(title)}&show_window=yes&edit=yes`, {
background: false,
});
}

function NotePreviewAction({ note }: { note: Note }) {
return (
<Action.Push
Expand Down

0 comments on commit 79ae43d

Please sign in to comment.