Skip to content

Commit 0b5c847

Browse files
Merge pull request #55 from PDFilez/research-mode
Research mode
2 parents 4d1eb8c + d9043cb commit 0b5c847

File tree

13 files changed

+69
-14
lines changed

13 files changed

+69
-14
lines changed

extension/icons/button-icons/note.svg

-1
This file was deleted.

extension/icons/donate.svg

-1
This file was deleted.

extension/icons/github.svg

-3
This file was deleted.

extension/icons/logo-128.png

-7.62 KB
Binary file not shown.

extension/icons/logo-48.png

-2.54 KB
Binary file not shown.

extension/icons/logo-96.png

-5.7 KB
Binary file not shown.

extension/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"description": " Organize research from websites & PDFs. Categorize highlights, images, links, notes",
33
"manifest_version": 3,
44
"name": "Snipd",
5-
"version": "0.0.0.7",
5+
"version": "0.0.0.8",
66
"homepage_url": "https://github.com/PDFilez/snipd",
77
"icons": {
88
"48": "images/snipdLogo8.png"

extension/src/data/configs.js

+1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ const configs = {
66
'borderRadius': 3,
77
'shiftTooltipWhenWebsiteHasOwn': false,
88
'draggableTooltip': false,
9+
'dontSnapTextfieldSelection': true,
910
'enabled': true,
1011
'hideOnKeypress': true,
1112
'middleClickHidesTooltip': false,

extension/src/functions/background.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,14 @@ chrome.runtime.onConnect.addListener(function (port) {
3232
}
3333
});
3434

35-
chrome.runtime.onInstalled.addListener((details) => {
35+
chrome.runtime.onInstalled.addListener(async (details) => {
3636
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
3737
chrome.tabs.create({
3838
url: "https://snipd-landing.vercel.app/",
3939
});
40+
await chrome.storage.local.set({"tooltip_enabled": true})
41+
await chrome.storage.local.set({"last_category": "Default"})
42+
4043
}
4144
});
4245

extension/src/index.css

+3-3
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@
7070

7171
background: black;
7272

73-
/* apply clip-path for future blurred tooltip option */
74-
/* clip-path: polygon(0% 100%, 100% 0%, 100% 100%) !important; */
7573
}
7674

7775
/* Buttons */
@@ -116,10 +114,12 @@
116114
transition: transform var(--selecton-anim-duration) ease-out,
117115
opacity var(--selecton-anim-duration) ease-out !important;
118116
opacity: 0;
119-
/* z-index: 100001 !important; */
120117
z-index: -1;
121118
position: absolute;
122119
margin: 0px !important;
120+
overflow: auto;
121+
max-height: 200px;
122+
min-width: 100px;
123123
padding: 6px !important;
124124
line-height: 1 !important;
125125
border: 0.25px solid var(--selecton-outline-color);

extension/src/index.js

+40
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ function initMouseListeners() {
134134
}
135135
} catch (e) { }
136136

137+
checkTextField(e, activeEl);
138+
139+
137140
if (selectedText.length > 0) {
138141
/// create tooltip for selection
139142
setCssStyles();
@@ -169,6 +172,43 @@ function initMouseListeners() {
169172
}, 0);
170173
}
171174

175+
function checkTextField(e, activeEl) {
176+
/// check if textfield is focused
177+
178+
isTextFieldFocused = (activeEl.tagName === "INPUT" && (activeEl.getAttribute('type') == 'text' || activeEl.getAttribute('type') == 'email' || activeEl.getAttribute('name') == 'text')) ||
179+
activeEl.tagName === "TEXTAREA" ||
180+
activeEl.getAttribute('contenteditable') !== null;
181+
182+
if (isTextFieldFocused && configs.addActionButtonsForTextFields) {
183+
184+
/// Special handling for Firefox
185+
/// (https://stackoverflow.com/questions/20419515/window-getselection-of-textarea-not-working-in-firefox)
186+
if (selectedText == '' && navigator.userAgent.indexOf("Firefox") > -1) {
187+
const ta = document.querySelector(':focus');
188+
if (ta != null && ta.value != undefined) {
189+
selectedText = ta.value.substring(ta.selectionStart, ta.selectionEnd);
190+
selection = ta.value.substring(ta.selectionStart, ta.selectionEnd);
191+
}
192+
}
193+
194+
/// Hide previous 'paste' button
195+
// if (selectedText == '') hideTooltip();
196+
197+
/// Ignore single click on text field with inputted value
198+
try {
199+
isTextFieldEmpty = true;
200+
if (activeEl.getAttribute('contenteditable') != null && activeEl.innerHTML != '' && selectedText == '' && activeEl.innerHTML != '<br>') {
201+
isTextFieldEmpty = false;
202+
if (configs.addPasteOnlyEmptyField) isTextFieldFocused = false;
203+
} else if (activeEl.value && activeEl.value.trim() !== '' && selectedText == '') {
204+
isTextFieldEmpty = false;
205+
if (configs.addPasteOnlyEmptyField) isTextFieldFocused = false;
206+
}
207+
} catch (e) { console.log(e); }
208+
}
209+
}
210+
211+
172212
function initTooltip(e) {
173213

174214
createTooltip(e);

popup/src/components/CategoriesMenuMantine.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const CategoriesMenuMantine = ({ category, addCategory, categoriesList, setCateg
3131
variant="light"
3232
color="rgba(73, 152, 201, 1)">
3333
Category:
34+
{console.log(category)}
3435
<Button style={{ color: "rgba(196, 77, 77, 1)" }} variant="transparent" size="sm">
3536
{category}
3637
<EditIcon size={14} />

popup/src/components/Note.jsx

+19-4
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,10 @@ const Note = ({ snipd }) => {
5656
setSnipdCategories((old) => [...old, newCategory]);
5757
};
5858

59-
const handleSaveSnippet = () => {
59+
const handleSaveSnippet = async () => {
6060
snipd.category = category;
61+
await chrome.storage.local.set({"last_category": category})
62+
6163
snipd.customNotes = customNotes;
6264
(snipd.id = uuidv4()),
6365
saveSnipd(snipd).then(() => {
@@ -71,11 +73,10 @@ const Note = ({ snipd }) => {
7173
};
7274

7375
const handleErrorClick = () => {
74-
setErrorFlag(false);
75-
setErrorMessage("");
76+
setErrorFlag(false); setErrorMessage("");
7677
};
7778

78-
useEffect(() => {
79+
useEffect(async () => {
7980
const fetchData = async () => {
8081
try {
8182
const categories = await fetchSnipdCategories();
@@ -85,9 +86,23 @@ const Note = ({ snipd }) => {
8586
}
8687
};
8788

89+
// chrome.storage.local.get("last_category", (data) => {
90+
// const last_category = data?.last_category
91+
// setCategory(last_category)
92+
93+
// });
94+
8895
fetchData();
8996
}, []);
9097

98+
useEffect(() => {
99+
chrome.storage.local.get("last_category", (data) => {
100+
console.log(data)
101+
const last_category = data?.last_category
102+
setCategory(last_category)
103+
});
104+
}, []);
105+
91106
return (
92107
<div className="container">
93108
<div className="card-content">

0 commit comments

Comments
 (0)