-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Undo del, import/export/setting (#30)
thanks to @badduck32
- Loading branch information
Showing
17 changed files
with
1,794 additions
and
696 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,32 @@ | ||
# Tab Notes | ||
Open new tab and write anything. | ||
|
||
## Features: | ||
|
||
* **Easy-to-use**: Just open new tab, and write down thoughts. | ||
* **Auto-save**: No worries about saving things when writing. | ||
* **Theme**: Support light and dark theme. | ||
* **Lightweight and fast** | ||
* **Multi-notes** | ||
* **Browser-action with shortcut**: You could use it without changing your current new tab page | ||
* Open-source | ||
|
||
## Shortcuts | ||
|
||
- `Ctrl/Cmd + Y`: To open the browser-action tab notes. | ||
|
||
## Download | ||
|
||
Tab Notes is available to the following browsers: | ||
* [Firefox](https://addons.mozilla.org/firefox/addon/tab-notes/) | ||
* [Chrome](https://chrome.google.com/webstore/detail/tab-notes/obnnegakmgonaiplaobihpmcjhlceeic) | ||
|
||
## Screenshot | ||
|
||
 | ||
# Tab Notes | ||
Open a new tab and write anything. | ||
|
||
## Features: | ||
|
||
* **Easy-to-use**: Just open new tab, and write down thoughts. | ||
* **Auto-save**: No worries about saving things when writing. | ||
* **Cloud sync**: Automatically save your notes across devices using GitHub gists. | ||
* **Theme**: Support light and dark theme. | ||
* **Lightweight and fast** | ||
* **Multiple notes**: Create as many notes as you like. | ||
* **Browser-action with shortcut**: You could use it without changing your current new tab page. | ||
* **Customization**: Edit font, font size and more. | ||
* **Images**: Paste images in your notes. | ||
* **Styled text**: Make your text bold, italic or underlined. | ||
* **Links**: Paste links to websites | ||
* Open-source | ||
|
||
## Shortcuts | ||
|
||
- `Ctrl/Cmd + Y`: To open the browser-action tab notes. | ||
|
||
## Download | ||
|
||
*These downloads don't include any changes from this fork* | ||
Tab Notes is available to the following browsers: | ||
* [Firefox](https://addons.mozilla.org/firefox/addon/tab-notes/) | ||
* [Chrome](https://chrome.google.com/webstore/detail/tab-notes/obnnegakmgonaiplaobihpmcjhlceeic) | ||
|
||
## Screenshot | ||
|
||
 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,18 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Export Page | Tab Notes</title> | ||
<script type="text/javascript" src="./browser-polyfill.min.js"></script> | ||
<script type="text/javascript" src="./migration.js"></script> | ||
<script type="text/javascript" src="./utils.js"></script> | ||
<script type="text/javascript" src="./export.js"></script> | ||
</head> | ||
<body> | ||
<h1>Tab Notes - Export Page</h1> | ||
<textarea id='export-content' style='width: 50vw; height: 75vh;'> | ||
</textarea> | ||
|
||
<button id='switch-button' data-current-ask="json">I need json file.</button> | ||
</body> | ||
</html> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Export Page | Tab Notes</title> | ||
<script type="text/javascript" src="./browser-polyfill.min.js"></script> | ||
<script type="text/javascript" src="./migration.js"></script> | ||
<script type="text/javascript" src="./utils.js"></script> | ||
<script type="text/javascript" src="./export.js"></script> | ||
</head> | ||
<body> | ||
<h1>Tab Notes - Export Page</h1> | ||
<div>All notes are delimited with "<<>>"</div> | ||
<textarea id='export-content' style='width: 50vw; height: 75vh;' readonly></textarea> | ||
<button id='copy-button' data-current-ask="json">Copy to clipboard</button> | ||
<button id='save-button' data-current-ask="json">Save to file</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,54 @@ | ||
;(() => { | ||
const exportJs = () => { | ||
const init = async () => { | ||
const $textarea = document.querySelector('#export-content') | ||
const $switchBtn = document.querySelector('#switch-button') | ||
const data = await window.utils.loadPreference() | ||
|
||
const notes = data.list | ||
.map(note => note.content) | ||
.filter(c => c) | ||
.join('\n\n--------------------\n\n') | ||
|
||
$textarea.value = notes | ||
|
||
$switchBtn.addEventListener('click', () => { | ||
const { currentAsk } = $switchBtn.dataset | ||
|
||
if (currentAsk === 'json') { | ||
$textarea.value = JSON.stringify(data, null, ' ') | ||
$switchBtn.dataset.currentAsk = 'text' | ||
$switchBtn.textContent = 'I need pure text.' | ||
} | ||
|
||
if (currentAsk === 'text') { | ||
$textarea.value = notes | ||
$switchBtn.dataset.currentAsk = 'json' | ||
$switchBtn.textContent = 'I need json file.' | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
init | ||
} | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
exportJs().init() | ||
}) | ||
})() | ||
|
||
;(() => { | ||
const exportJs = () => { | ||
const init = async () => { | ||
const $textarea = document.querySelector('#export-content') | ||
const $copyBtn = document.querySelector('#copy-button') | ||
const $saveBtn = document.querySelector('#save-button') | ||
const data = await window.utils.loadPreference() | ||
|
||
const notes = data.list | ||
.map(note => `${note.content}\n\n<<${note.time}>>\n\n`) | ||
.filter(c => c) | ||
.join('') | ||
|
||
$textarea.value = notes | ||
|
||
$copyBtn.addEventListener('click', async () => { | ||
try { | ||
await navigator.clipboard.writeText($textarea.value); | ||
console.log('Notes copied to clipboard'); | ||
} catch (err) { | ||
alert('Failed to copy: ', err); | ||
} | ||
}) | ||
|
||
$saveBtn.addEventListener('click', async () => { | ||
var userInput = $textarea.value; | ||
|
||
var blob = new Blob([userInput], { type: "text/plain;charset=utf-8" }); | ||
|
||
let newLink = document.createElement("a"); | ||
newLink.download = "export.txt"; | ||
|
||
if (window.webkitURL != null) { | ||
newLink.href = window.webkitURL.createObjectURL(blob); | ||
} else { | ||
newLink.href = window.URL.createObjectURL(blob); | ||
newLink.style.display = "none"; | ||
document.body.appendChild(newLink); | ||
} | ||
|
||
newLink.click(); | ||
}) | ||
} | ||
|
||
return { | ||
init | ||
} | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
exportJs().init() | ||
}) | ||
})() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Import Page | Tab Notes</title> | ||
<script type="text/javascript" src="./browser-polyfill.min.js"></script> | ||
<script type="text/javascript" src="./migration.js"></script> | ||
<script type="text/javascript" src="./utils.js"></script> | ||
<script type="text/javascript" src="./import.js"></script> | ||
</head> | ||
<body> | ||
<h1>Tab Notes - Import Page</h1> | ||
<div>Paste your exported notes here.</div> | ||
<textarea id='import-content' style='width: 50vw; height: 75vh;'></textarea> | ||
<button id='import-button' data-current-ask="json">Import</button> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
;(() => { | ||
const importJs = () => { | ||
const init = async () => { | ||
const $textarea = document.querySelector('#import-content') | ||
const $importBtn = document.querySelector('#import-button') | ||
const data = await window.utils.loadPreference() | ||
|
||
$importBtn.addEventListener('click', () => { | ||
if (confirm("Are you sure you want to import these notes? All of your current notes will be replaced. This action cannot be undone.")) { | ||
console.log("replacing") | ||
var tmp = $textarea.value | ||
.split(/\n\n<<([0-9]+)>>\n\n/g) | ||
.slice(0, -1) | ||
var newnotes = [] | ||
for (var i = 0; i < tmp.length; i += 2) { | ||
newnotes.push({content: tmp[i], time: parseInt(tmp[i+1])}) | ||
} | ||
|
||
data.list = newnotes | ||
browser.storage.local.set({ list: data.list }) | ||
} | ||
}) | ||
} | ||
|
||
return { | ||
init | ||
} | ||
} | ||
|
||
window.addEventListener('load', () => { | ||
importJs().init() | ||
}) | ||
})() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
{ | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]", | ||
"strict_min_version": "54.0a1" | ||
} | ||
}, | ||
"icons": { | ||
"48": "icons/48.png", | ||
"96": "icons/96.png", | ||
"128": "icons/128.png", | ||
"256": "icons/256.png" | ||
}, | ||
"manifest_version": 2, | ||
"name": "Tab Notes", | ||
"version": "3.2.0", | ||
"description": "Allow you to write anything in new tab", | ||
"permissions": [ | ||
"storage", "unlimitedStorage" | ||
], | ||
"chrome_url_overrides": { | ||
"newtab": "newtab.html" | ||
}, | ||
|
||
"browser_action": { | ||
"browser_style": true, | ||
"default_icon": "icons/48.png", | ||
"default_title": "Tab notes", | ||
"default_popup": "newtab.html" | ||
}, | ||
|
||
"commands": { | ||
"_execute_browser_action": { | ||
"suggested_key": { | ||
"default": "Ctrl+Y" | ||
} | ||
} | ||
} | ||
} | ||
{ | ||
"applications": { | ||
"gecko": { | ||
"id": "[email protected]", | ||
"strict_min_version": "54.0a1" | ||
} | ||
}, | ||
"icons": { | ||
"48": "icons/48.png", | ||
"96": "icons/96.png", | ||
"128": "icons/128.png", | ||
"256": "icons/256.png" | ||
}, | ||
"manifest_version": 2, | ||
"name": "Tab Notes", | ||
"version": "3.2.0", | ||
"description": "Allow you to write anything in new tab", | ||
"permissions": [ | ||
"storage", "unlimitedStorage" | ||
], | ||
"chrome_url_overrides": { | ||
"newtab": "newtab.html" | ||
}, | ||
"web_accessible_resources": [ | ||
"https://esm.sh/@octokit/request.js/" | ||
], | ||
|
||
"browser_action": { | ||
"browser_style": true, | ||
"default_icon": "icons/48.png", | ||
"default_title": "Tab notes", | ||
"default_popup": "newtab.html" | ||
}, | ||
|
||
"commands": { | ||
"_execute_browser_action": { | ||
"suggested_key": { | ||
"default": "Ctrl+Y" | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.