Skip to content

Commit 990bf35

Browse files
authored
Merge pull request #41 from betterRunner/dev
Dev
2 parents f1c08df + 35105cf commit 990bf35

File tree

8 files changed

+97
-42
lines changed

8 files changed

+97
-42
lines changed

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
1+
## [1.3.7](https://github.com/betterRunner/context-note/compare/v1.2.2...v1.3.7) (2022-01-02)
2+
3+
4+
### Bug Fixes
5+
6+
* put the notes with the current location href to the head. ([81360db](https://github.com/betterRunner/context-note/commit/81360db9c0fcf46e5c98dcec9daf89372775b2fe))
7+
* clear search text when tag-searcher close ([56b0f2b](https://github.com/betterRunner/context-note/commit/56b0f2b2e78984a6691f5c8003b8779cd2b539be))
8+
* close button ([a2f46fd](https://github.com/betterRunner/context-note/commit/a2f46fd45ab62df661c3ee1335a4855e4e23caed))
9+
* close icon ([e9803dc](https://github.com/betterRunner/context-note/commit/e9803dcb2ca44f1a4f813695efaea018daebbdec))
10+
* css on windows ([4e6f22c](https://github.com/betterRunner/context-note/commit/4e6f22ca5cfd43f25500bf63c78d064e3bbe778e))
11+
* el-overlay z-index ([7e7b62d](https://github.com/betterRunner/context-note/commit/7e7b62df0dec2d7f0e821426252e92e8a419bba1))
12+
* handleClickOutsideEditor trigger bug ([045c6c8](https://github.com/betterRunner/context-note/commit/045c6c8c8f352928a0156f861560d2acd10f9624))
13+
* hightlight rects not occupying click event ([f0d4e07](https://github.com/betterRunner/context-note/commit/f0d4e07b3b7af6346cb4c59728b78b757a41a730))
14+
* keep query of url of note ([12dbe48](https://github.com/betterRunner/context-note/commit/12dbe48095fcf4ebf93a5b5a3b86e839239cfa12))
15+
* more button top ([4032321](https://github.com/betterRunner/context-note/commit/40323213559fca34ea12d4fac55f8fc72f2a8c8c))
16+
* note width in expaned mode & clickoutside ([5ae6c6b](https://github.com/betterRunner/context-note/commit/5ae6c6bcbfe63fa945c25ce19f1d9df36a316e8c))
17+
* padding & scrollbar ([ecedbb7](https://github.com/betterRunner/context-note/commit/ecedbb76d29d0b098bf7bd5995e5b3c41ed7621e))
18+
* popup is hided in small screen ([0950940](https://github.com/betterRunner/context-note/commit/0950940d7d1d668a22d1289989e03c976ff57710))
19+
* scrollbar of page disappers ([3f5dc31](https://github.com/betterRunner/context-note/commit/3f5dc319dc0149dbf18863ec2d66ca92ad124752))
20+
* storage write not working ([bf5827b](https://github.com/betterRunner/context-note/commit/bf5827b56b1f5cc02ac53d37554d85b44d9500ed))
21+
* tag & more css ([b88539f](https://github.com/betterRunner/context-note/commit/b88539fc2a1790ab1c59c3b946a1c8ec0c64b732))
22+
* wait to run storage oper until prev one finished ([64e3806](https://github.com/betterRunner/context-note/commit/64e38062388e533048507ac34bbeb0ba50e9c5f5))
23+
24+
25+
### Features
26+
27+
* copy note to clipboard ([403f7f7](https://github.com/betterRunner/context-note/commit/403f7f7460f1ce9ad086ae9477cc7f2a0acb7007))
28+
* import notes ([74857b1](https://github.com/betterRunner/context-note/commit/74857b12d45ba41cd0bb1a6db4823134a419f884))
29+
30+
31+
132
## [1.3.6](https://github.com/betterRunner/context-note/compare/v1.2.2...v1.3.6) (2021-12-25)
233

334

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "context-note",
3-
"version": "1.3.6",
3+
"version": "1.3.7",
44
"scripts": {
55
"dev": "vite build --mode developmemnt",
66
"build": "vite build",

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export default defineComponent({
3434
appWidth.value = e ? AppWidth.expanded : AppWidth.normal;
3535
});
3636
const wrapperStyle = computed(() => {
37-
const maxWidth = window.innerWidth * 0.8;
37+
const maxWidth = window.innerWidth * 0.9;
3838
const width = appWidth.value > maxWidth ? maxWidth : appWidth.value;
3939
return {
4040
width: `${width}px`,

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ export default defineComponent({
9898
};
9999
100100
// 1. create the note item
101+
const href = window.location.href;
101102
const note: TNote = {
102103
id: noteId,
103104
createTime: dayjs().unix(),
104105
updateTime: dayjs().unix(),
105-
link: removeUrlPostfix(window.location.href),
106+
link: removeUrlPostfix(href),
107+
rawLink: href,
106108
linkTitle: window.document.title ?? '',
107109
content: text,
108110
rects: rects,
@@ -198,13 +200,14 @@ export default defineComponent({
198200
};
199201
200202
/// doms
201-
const domNoteList = (notes: TNote[]) => {
203+
const domNoteList = (notes: TNote[], expanded?: boolean) => {
202204
return notes.map((note, i) => (
203205
<Note
204206
ref={(el: any) => {
205207
noteDivs.value[i] = el;
206208
}}
207209
note={note as TNote}
210+
expanded={expanded}
208211
curNoteId={curNoteId.value}
209212
onDelete={() => handleDeleteNote(note as TNote)}
210213
onUpdateNoteNote={handleUpdateNoteNote}
@@ -218,7 +221,7 @@ export default defineComponent({
218221
const domTag = (title: string = "", notes: TNote[] = []) => (
219222
<div class="note-list-tag">
220223
<div class="note-list-tag-title">{title}</div>
221-
<div class="note-list-wrap-container">{domNoteList(notes)}</div>
224+
<div class="note-list-wrap-container">{domNoteList(notes, true)}</div>
222225
</div>
223226
);
224227
if (tags.length) {
@@ -239,7 +242,7 @@ export default defineComponent({
239242
return domTags;
240243
} else {
241244
return (
242-
<div class="note-list-wrap-container">{domNoteList(searchedNotes.value)}</div>
245+
<div class="note-list-wrap-container">{domNoteList(searchedNotes.value, true)}</div>
243246
);
244247
}
245248
};

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

+19-15
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
<div
33
class="note-wrapper"
44
:class="{ 'note-wrapper__notselected': notSelected }"
5-
:style="colorBarStyle"
5+
:style="wrapperStyle"
66
@click="handleClickNote"
7+
v-clickoutside="handleClickOutsideNote"
78
>
89
<!-- website link -->
910
<div :id="`link-${note.id}`" class="note-link">
@@ -75,7 +76,7 @@ import { Storage } from "@/types/storage";
7576
import { Coor, Oper } from "@/types/common";
7677
import { Query } from "@/types/dom";
7778
import mitt from "@/utils/mitt";
78-
import { wrapUrlWithQuery } from "@/utils/utils";
79+
import { appendUrlQuery } from "@/utils/utils";
7980
import TagBook from "../tag-book/index.vue";
8081
import More from "../shared/more.vue";
8182
@@ -94,12 +95,17 @@ export default {
9495
required: true,
9596
type: Object as PropType<Note>,
9697
},
98+
expanded: {
99+
default: false,
100+
},
97101
},
98102
setup(props, ctx) {
99-
const colorBarStyle = ref({
103+
const wrapperStyle = ref({
100104
borderTop: `8px solid ${randomcolor({
101105
alpha: 0.5,
102106
})}`,
107+
width: `${props.expanded ? 420 : 460}px`,
108+
maxWidth: `${props.expanded ? 420 : 460}px`,
103109
});
104110
const storage: Storage = inject("storage", {
105111
notes: [],
@@ -112,15 +118,12 @@ export default {
112118
);
113119
114120
/// note link
115-
const noteLink = ref(props.note.link || "");
116-
const handleCopy = () => {
117-
ElMessage.success("Copied");
118-
};
119121
const handleOpenLink = (note: Note) => {
120122
const query: Query = {
121123
noteId: note.id,
122124
};
123-
const url = wrapUrlWithQuery(note.link, query);
125+
console.log(note.rawLink);
126+
const url = appendUrlQuery(note.rawLink, query);
124127
window.open(url);
125128
};
126129
@@ -136,8 +139,8 @@ export default {
136139
{
137140
title: "Copy to clipboard",
138141
onClick: () => {
139-
const { link = '', linkTitle = '', content = '', tags = [] } : Note = props.note;
140-
const text = `[${linkTitle || 'unknowned'}](${link})
142+
const { rawLink = '', linkTitle = '', content = '', tags = [] } : Note = props.note;
143+
const text = `[${linkTitle || 'unknowned'}](${rawLink})
141144
- ${content}
142145
${tags.join(',')}`;
143146
toClipboard(text);
@@ -206,6 +209,10 @@ export default {
206209
// make sure the select event is trigger after `handleClickOutsideEditor`
207210
nextTick(() => ctx.emit("select", props.note.id));
208211
};
212+
const handleClickOutsideNote = () => {
213+
// make sure the select event is trigger after `handleClickOutsideEditor`
214+
nextTick(() => ctx.emit("select", ""));
215+
}
209216
const handleClickEditor = () => {
210217
enableEditor.value = true;
211218
};
@@ -233,11 +240,9 @@ export default {
233240
234241
return {
235242
dayjs,
236-
colorBarStyle,
243+
wrapperStyle,
237244
notSelected,
238245
239-
noteLink,
240-
handleCopy,
241246
handleOpenLink,
242247
243248
moreOpers,
@@ -251,6 +256,7 @@ export default {
251256
editorContent,
252257
editorDom,
253258
handleClickNote,
259+
handleClickOutsideNote,
254260
handleClickEditor,
255261
handleClickOutsideEditor,
256262
};
@@ -270,8 +276,6 @@ export default {
270276
display: flex;
271277
flex-direction: column;
272278
justify-content: flex-start;
273-
width: 460px;
274-
max-width: 460px;
275279
box-sizing: border-box !important;
276280
height: 100%;
277281

src/manifest.json

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

src/types/note.ts

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export interface Note {
66
createTime: number;
77
updateTime: number;
88
link: string;
9+
rawLink: string;
910
linkTitle: string;
1011
content: string;
1112
tags: string[];

src/utils/utils.ts

+36-20
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,45 @@
1+
import appendQuery from 'append-query';
2+
13
export const isObject = (obj: any) => {
2-
return typeof obj === "object" && obj !== null;
3-
};
4+
return typeof obj === 'object' && obj !== null
5+
}
46

5-
export const getObjectType = (obj: any) => Object.prototype.toString.call(obj);
7+
export const getObjectType = (obj: any) => Object.prototype.toString.call(obj)
68

79
export const removeUrlPostfix = (url: string) => {
8-
let res = url.split("?")?.[0] ?? "";
9-
res = res.split("#")?.[0] ?? "";
10-
return res;
11-
};
10+
let res = url.split('?')?.[0] ?? ''
11+
res = res.split('#')?.[0] ?? ''
12+
return res
13+
}
1214

1315
export const getUrlQuery = (url: string) => {
14-
const queryStr = url.split("?")?.[1] ?? "";
16+
const queryStr = url.split('?')?.[1] ?? ''
1517
const res = Object.fromEntries(
16-
queryStr.split("&").map((part) => {
17-
return part.split("=");
18+
queryStr.split('&').map((part) => {
19+
return part.split('=')
1820
})
19-
);
20-
return res;
21-
};
21+
)
22+
return res
23+
}
24+
25+
// export const appendUrlQuery = (
26+
// url: string,
27+
// query: { [key: string]: any }
28+
// ) => {
29+
// return appendQuery(url, query)
30+
// }
2231

23-
export const wrapUrlWithQuery = (
24-
url: string,
25-
query: { [key: string]: any }
26-
) => {
27-
if (!query || Object.keys(query).length === 0) return url;
28-
return `${url}?${Object.entries(query).map(e => e.join('=')).join('&')}`;
29-
};
32+
export const appendUrlQuery = (
33+
baseUrl: string,
34+
params: Record<string, any>
35+
): string => {
36+
const Url = new URL(baseUrl);
37+
const urlParams: URLSearchParams = new URLSearchParams(Url.search);
38+
for (const key in params) {
39+
if (params[key] !== undefined) {
40+
urlParams.set(key, params[key]);
41+
}
42+
}
43+
Url.search = urlParams.toString();
44+
return Url.toString();
45+
};

0 commit comments

Comments
 (0)