Skip to content

Commit 57ee4a8

Browse files
authored
Merge pull request #35 from betterRunner/dev
Dev
2 parents 352a776 + 7e7b75e commit 57ee4a8

File tree

12 files changed

+67
-15
lines changed

12 files changed

+67
-15
lines changed

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,23 @@
1+
## [1.3.5](https://github.com/betterRunner/context-note/compare/v1.3.2...v1.3.5) (2021-11-16)
2+
3+
4+
### Bug Fixes
5+
6+
* clear search text when tag-searcher close ([56b0f2b](https://github.com/betterRunner/context-note/commit/56b0f2b2e78984a6691f5c8003b8779cd2b539be))
7+
* close button ([a2f46fd](https://github.com/betterRunner/context-note/commit/a2f46fd45ab62df661c3ee1335a4855e4e23caed))
8+
* handleClickOutsideEditor trigger bug ([045c6c8](https://github.com/betterRunner/context-note/commit/045c6c8c8f352928a0156f861560d2acd10f9624))
9+
* hightlight rects not occupying click event ([f0d4e07](https://github.com/betterRunner/context-note/commit/f0d4e07b3b7af6346cb4c59728b78b757a41a730))
10+
* more button top ([4032321](https://github.com/betterRunner/context-note/commit/40323213559fca34ea12d4fac55f8fc72f2a8c8c))
11+
* tag & more css ([b88539f](https://github.com/betterRunner/context-note/commit/b88539fc2a1790ab1c59c3b946a1c8ec0c64b732))
12+
* wait to run storage oper until prev one finished ([64e3806](https://github.com/betterRunner/context-note/commit/64e38062388e533048507ac34bbeb0ba50e9c5f5))
13+
14+
15+
### Features
16+
17+
* copy note to clipboard ([403f7f7](https://github.com/betterRunner/context-note/commit/403f7f7460f1ce9ad086ae9477cc7f2a0acb7007))
18+
19+
20+
121
## [1.3.4](https://github.com/betterRunner/context-note/compare/v1.3.2...v1.3.4) (2021-11-07)
222

323

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "context-note",
3-
"version": "1.3.4",
3+
"version": "1.3.5",
44
"scripts": {
55
"dev": "vite build --mode developmemnt",
66
"build": "vite build",

src/content-scripts/main.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ body {}
22

33
/* Rewrite el-popper and el-overlay z-index, should be higher than extension mask z-index */
44
.el-popper, .el-overlay {
5+
padding: 5px !important;
56
z-index: 10001 !important;
67
}
78

src/content-scripts/renderer/dom/rect.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@ import {
55
PREFIX_RECT,
66
PREFIX_RECT_GROUP,
77
} from "@/utils/constant";
8+
import { EnumValueVisiteeWithNull } from "ts-enum-util";
89

910
function setHighlightStyle(ele: HTMLElement, rect: Rect) {
1011
const PADDING = 6;
12+
ele.style.pointerEvents = "none"; // not occupy the click event of the node in this position
1113
ele.style.position = "absolute";
1214
ele.style.left = rect.x - PADDING / 2 + "px";
1315
ele.style.top = rect.y - PADDING / 2 + "px";
@@ -43,7 +45,7 @@ function setRectStyleWithIds(ids: string[], key: string, value: string) {
4345
}
4446

4547
const groupRectIdsMap: { [key: string]: string[] } = {};
46-
/**
48+
/**
4749
* Generate the highlight rect doms and register their click event.
4850
*/
4951
export function genHighlightRects(
@@ -65,8 +67,11 @@ export function genHighlightRects(
6567

6668
// click event
6769
document.addEventListener("mouseup", (event) => {
68-
const withinBoundaries = event.composedPath().includes(ele);
69-
70+
const withinBoundaries =
71+
event.pageX >= ele.offsetLeft &&
72+
event.pageX <= ele.offsetWidth + ele.offsetLeft &&
73+
event.pageY >= ele.offsetTop &&
74+
event.pageY <= ele.offsetHeight + ele.offsetTop;
7075
if (withinBoundaries) {
7176
const groupId = boldHighlightGroupRects(ele?.id, "");
7277
clickCb?.(groupId);
@@ -78,15 +83,17 @@ export function genHighlightRects(
7883
return groupId;
7984
}
8085

81-
/**
86+
/**
8287
* Delete all rects with `noteId`, if `noteId` is not provided, delete all rects.
8388
*/
8489
export function delHighlightRects(noteId?: string | undefined) {
85-
const query = !noteId ? `[${DOMATTR_RECT_GROUP}]` : `[${DOMATTR_RECT_GROUP}=${noteId}]`
90+
const query = !noteId
91+
? `[${DOMATTR_RECT_GROUP}]`
92+
: `[${DOMATTR_RECT_GROUP}=${noteId}]`;
8693
const rectDoms = document.querySelectorAll(query);
87-
rectDoms.forEach(dom => {
94+
rectDoms.forEach((dom) => {
8895
dom.parentElement?.removeChild(dom);
89-
})
96+
});
9097
}
9198

9299
/**

src/content-scripts/renderer/popup/index.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<template>
22
<div v-show="visible">
33
<div class="popup-wrapper" :style="wrapperStyle">
4+
<el-icon class="popup-close" @click="handleClose"><Close /></el-icon>
45
<NoteBook :expanded="appExpanded" v-clickoutside="handleClickOutside" />
56
<Footer :width="appWidth" />
67
</div>
@@ -9,6 +10,7 @@
910

1011
<script lang="ts">
1112
import { defineComponent, provide, ref, reactive, computed } from "vue";
13+
import { Close } from "@element-plus/icons";
1214
import NoteBook from "./note-book/index.vue";
1315
import Footer from "./footer/index.vue";
1416
import { Note } from "@/types/note";
@@ -20,6 +22,7 @@ import { StorageKeys, AppWidth } from "@/utils/constant";
2022
2123
export default defineComponent({
2224
components: {
25+
Close,
2326
NoteBook,
2427
Footer,
2528
},
@@ -44,6 +47,9 @@ export default defineComponent({
4447
const handleClickOutside = () => {
4548
visible.value = false;
4649
};
50+
const handleClose = () => {
51+
visible.value = false;
52+
}
4753
4854
// global reading `notes` and `tags` from storage and provide to sub components.
4955
const storage = reactive<Storage>({
@@ -72,6 +78,7 @@ export default defineComponent({
7278
wrapperStyle,
7379
visible,
7480
handleClickOutside,
81+
handleClose,
7582
};
7683
},
7784
});
@@ -90,5 +97,12 @@ export default defineComponent({
9097
opacity: 1;
9198
border-radius: 10px;
9299
z-index: 9999;
100+
101+
.popup-close {
102+
position: absolute;
103+
right: 5px;
104+
top: 5px;
105+
cursor: pointer;
106+
}
93107
}
94108
</style>

src/content-scripts/renderer/popup/note-book/note-list.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,8 @@ export default defineComponent({
138138
const { noteId = "", tag = "", isAddOrDelete = false } = data as any;
139139
const fn = isAddOrDelete ? addItemToArrProperty : delItemFromArrProperty;
140140
storage.notes = await fn(StorageKeys.notes, "id", noteId, "tags", tag);
141+
142+
mitt.emit("update-note-tag-cb");
141143
});
142144
143145
/// update note of note

src/content-scripts/renderer/popup/note-book/note.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ export default {
353353
}
354354
.note-more-opers {
355355
position: absolute;
356-
top: 10px;
356+
top: 5px;
357357
right: 10px;
358358
cursor: pointer;
359359
padding: 5px;

src/content-scripts/renderer/popup/shared/more.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export default {
107107
.more-opers-item {
108108
cursor: pointer;
109109
user-select: none;
110-
padding: 10px;
110+
padding: 5px;
111111
&:hover {
112112
background: #ccc;
113113
}

src/content-scripts/renderer/popup/tag-book/index.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import randomColor from "randomcolor";
2222
import { Coor } from "@/types/common";
2323
import { Tag } from "@/types/tag";
2424
import { Storage } from "@/types/storage";
25-
import mitt from "@/utils/mitt";
25+
import mitt, { sendEmitAndWait } from "@/utils/mitt";
2626
import {
2727
addItemToArr,
2828
addItemToArrProperty,
@@ -91,6 +91,7 @@ export default {
9191
);
9292
const handleClickOutside = () => {
9393
ctx.emit("close");
94+
mitt.emit('tag-search-clear');
9495
};
9596
9697
const storage: Storage = inject("storage", {
@@ -149,7 +150,7 @@ export default {
149150
} else {
150151
tag.isSelect = !tag.isSelect;
151152
if (tag.isSelect) {
152-
mitt.emit("update-note-tag", {
153+
await sendEmitAndWait("update-note-tag", {
153154
noteId: props.noteId,
154155
tag: tag.name,
155156
isAddOrDelete: true,
@@ -162,7 +163,7 @@ export default {
162163
props.noteId
163164
);
164165
} else {
165-
mitt.emit("update-note-tag", {
166+
await sendEmitAndWait("update-note-tag", {
166167
noteId: props.noteId,
167168
tag: tag.name,
168169
isAddOrDelete: false,

src/content-scripts/renderer/popup/tag-book/tag-searcher.vue

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export default {
3636
}
3737
);
3838
const taginput = ref(null);
39+
mitt.on('tag-search-clear', () => {
40+
searchText.value = "";
41+
})
3942
mitt.on('tag-search-focus', () => {
4043
(taginput.value as unknown as HTMLElement)?.focus();
4144
})

src/content-scripts/renderer/popup/tag-book/tag-selector/tag-list.vue

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
@click="handleSelectTagItem(tag)"
1313
>
1414
<div class="tag-item-content">
15-
<el-icon v-if="tag.isSelect" :size="12"><Check /></el-icon>
15+
<el-icon class="tag-item-icon" v-if="tag.isSelect" :size="12"><Check /></el-icon>
1616
{{ tag.name }}
1717
</div>
1818
</el-tag>
@@ -77,6 +77,10 @@ export default {
7777
.tag-item-content {
7878
display: flex;
7979
align-items: center;
80+
.tag-item-icon {
81+
top: 0 !important;
82+
right: 0 !important;
83+
}
8084
}
8185
}
8286
}

src/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "context-note",
3-
"version": "1.3.4",
3+
"version": "1.3.5",
44
"manifest_version": 3,
55
"action": {
66
"default_icon": {

0 commit comments

Comments
 (0)