Skip to content

Commit

Permalink
Merge pull request #2 from benji300/release-1.1
Browse files Browse the repository at this point in the history
Release v1.1.0
  • Loading branch information
benji300 committed Jan 20, 2021
2 parents b51f3f2 + 3f0daba commit 8d981c7
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 28 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- None

## [1.1.0] - 2021-01-21

### Changed

- Improve style of scrollbar in vertical layout

### Fixed

- Edited search queries not saved
- Reduced opactiy of dragging favorite

## [1.0.0] - 2020-01-18

- Initial Release
2 changes: 1 addition & 1 deletion 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "joplin-plugin-benji-favorites",
"version": "1.0.0",
"version": "1.1.0",
"description": "Save any notebook, note, to-do, tag, or search as favorite in an extra panel view for quick access.",
"author": "Benji300",
"homepage": "https://github.com/benji300/joplin-favorites",
Expand Down
19 changes: 14 additions & 5 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,24 @@ export class Favorites {
}

/**
* Changes the name of the handled favorite.
* Changes the title of the handled favorite.
*/
async rename(value: string, newTitle: string) {
async changeValue(value: string, newValue: string) {
if (!newValue) return;
const index: number = this.indexOf(value);
if (index < 0) return;
this._favs[index].value = newValue;
await this.store();
}

let favorite: any = this._favs[index];
favorite.title = newTitle;
this._favs.splice(index, 1, favorite);
/**
* Changes the title of the handled favorite.
*/
async changeTitle(value: string, newTitle: string) {
if (!newTitle) return;
const index: number = this.indexOf(value);
if (index < 0) return;
this._favs[index].title = newTitle;
await this.store();
}

Expand Down
10 changes: 4 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ joplin.plugins.register({
if (newType) {
await favorites.changeType(favorite.value, newType);
await updatePanelView();
return;
}
}

Expand Down Expand Up @@ -363,11 +362,10 @@ joplin.plugins.register({
const result: any = await DIALOGS.open(dialogEdit);

// handle result
if (result.id == "ok") {
if (result.formData != null && result.formData.inputForm.title != '') {
await favorites.rename(value, result.formData.inputForm.title);
await updatePanelView();
}
if (result.id == "ok" && result.formData != null) {
await favorites.changeTitle(value, result.formData.inputForm.title);
await favorites.changeValue(value, result.formData.inputForm.value);
await updatePanelView();
} else if (result.id == "delete") {
await favorites.delete(value);
await updatePanelView();
Expand Down
4 changes: 2 additions & 2 deletions src/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
"manifest_version": 1,
"id": "joplin.plugin.benji.favorites",
"app_min_version": "1.6.5",
"version": "1.0.0",
"version": "1.1.0",
"name": "Favorites",
"description": "Save any notebook, note, to-do, tag, or search as favorite in an extra panel view for quick access. (v1.0.0)",
"description": "Save any notebook, note, to-do, tag, or search as favorite in an extra panel view for quick access. (v1.1.0)",
"author": "Benji300",
"homepage_url": "https://github.com/benji300/joplin-favorites",
"repository_url": "https://github.com/benji300/joplin-favorites"
Expand Down
23 changes: 13 additions & 10 deletions src/webview.css
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,6 @@ span {
overflow: initial;
}

::-webkit-scrollbar {
height: 4px;
width: 4px;
}
::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 10px;
}

/* HORIZONTAL LAYOUT */
#container {
height: 100%;
Expand Down Expand Up @@ -83,7 +74,15 @@ span {
-ms-user-select: none;
}
.dragging {
opacity: 0.4;
opacity: 0.4 !important;
}

::-webkit-scrollbar {
height: 4px;
}
::-webkit-scrollbar-thumb {
background: rgba(0, 0, 0, 0.2);
border-radius: 5px;
}

/* VERCTICAL LAYOUT OVERWRITES */
Expand Down Expand Up @@ -111,4 +110,8 @@ span {
padding-left: 24px;
text-align: left;
}

::-webkit-scrollbar {
width: 7px;
}
}
13 changes: 10 additions & 3 deletions src/webview.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function dragStart(event) {
const dataId = getDataId(event);
if (dataId) {
event.currentTarget.classList.add('dragging');
event.dataTransfer.setData('text/favorite-id', dataId);
event.dataTransfer.setData('text/x-plugin-favorites-id', dataId);
sourceId = dataId;
}
}
Expand Down Expand Up @@ -75,7 +75,7 @@ function dragLeave(event) {

function drop(event) {
cancelDefault(event);
const dataSourceId = event.dataTransfer.getData('text/favorite-id');
const dataSourceId = event.dataTransfer.getData('text/x-plugin-favorites-id');
if (dataSourceId) {
const dataTargetId = getDataId(event);
if (dataTargetId !== sourceId) {
Expand All @@ -87,7 +87,7 @@ function drop(event) {
function dropOnTitle(event) {
cancelDefault(event);

// check whether folder was dragged from app onto the panel - trigger favsAddNote then
// check whether folder was dragged from app onto the panel - trigger favsAddFolder then
const appDragFolderIds = event.dataTransfer.getData('text/x-jop-folder-ids');
if (appDragFolderIds) {
const folderIds = JSON.parse(appDragFolderIds);
Expand All @@ -105,4 +105,11 @@ function dropOnTitle(event) {
}
webviewApi.postMessage({ name: 'favsAddNote', id: ids });
}

// check whether tab (from joplin.plugin.note.tabs plugin) was dragged onto the panel - trigger favsAddNote then
const appDragTabId = event.dataTransfer.getData('text/x-plugin-note-tabs-id'); // 'text/plain'
if (appDragTabId) {
const ids = new Array(appDragTabId);
webviewApi.postMessage({ name: 'favsAddNote', id: ids });
}
}

0 comments on commit 8d981c7

Please sign in to comment.