-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b7474a
commit 28d8001
Showing
7 changed files
with
182 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,18 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Online Notepad", | ||
"version": "1.0", | ||
"description": "A simple online notepad.", | ||
"action": { | ||
"default_popup": "popup.html", | ||
"default_icon": { | ||
"16": "icons/icon16.png", | ||
"48": "icons/icon48.png", | ||
"128": "icons/icon128.png" | ||
} | ||
}, | ||
"permissions": [ | ||
"storage" | ||
] | ||
} | ||
|
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,70 @@ | ||
body { | ||
font-family: "Helvetica Neue", Arial, sans-serif; | ||
background-color: #f0f4f8; | ||
margin: 0; | ||
padding: 0; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
|
||
.container { | ||
width: 100%; | ||
padding: 20px; | ||
background: #ffffff; | ||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); | ||
border-radius: 10px; | ||
} | ||
|
||
h1 { | ||
text-align: center; | ||
color: #333; | ||
margin-bottom: 20px; | ||
font-size: 1.5em; | ||
} | ||
|
||
.toolbar { | ||
display: flex; | ||
justify-content: center; | ||
margin-bottom: 10px; | ||
} | ||
|
||
.toolbar button { | ||
margin: 0 5px; | ||
padding: 10px; | ||
font-size: 16px; | ||
cursor: pointer; | ||
background: #007bff; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
transition: background-color 0.3s ease; | ||
} | ||
|
||
.toolbar button:hover { | ||
background-color: #0056b3; | ||
} | ||
|
||
.toolbar button i { | ||
pointer-events: none; | ||
} | ||
|
||
#notepad { | ||
width: 100%; | ||
height: 400px; | ||
padding: 20px; | ||
font-size: 16px; | ||
border: 1px solid #ccc; | ||
border-radius: 4px; | ||
box-sizing: border-box; | ||
overflow-y: auto; | ||
white-space: pre-wrap; | ||
background-color: #fdfdfd; | ||
color: #333; | ||
} | ||
|
||
#notepad:empty:before { | ||
content: attr(placeholder); | ||
color: #999; | ||
} |
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,53 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Online Notepad</title> | ||
<link rel="stylesheet" href="popup.css" /> | ||
<link | ||
rel="stylesheet" | ||
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" | ||
/> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>Online Notepad</h1> | ||
<div class="toolbar"> | ||
<button onclick="formatText('bold')"> | ||
<i class="fas fa-bold"></i> | ||
</button> | ||
<button onclick="formatText('italic')"> | ||
<i class="fas fa-italic"></i> | ||
</button> | ||
<button onclick="formatText('underline')"> | ||
<i class="fas fa-underline"></i> | ||
</button> | ||
<button onclick="formatText('justifyLeft')"> | ||
<i class="fas fa-align-left"></i> | ||
</button> | ||
<button onclick="formatText('justifyCenter')"> | ||
<i class="fas fa-align-center"></i> | ||
</button> | ||
<button onclick="formatText('justifyRight')"> | ||
<i class="fas fa-align-right"></i> | ||
</button> | ||
<button onclick="formatText('insertUnorderedList')"> | ||
<i class="fas fa-list-ul"></i> | ||
</button> | ||
<button onclick="formatText('insertOrderedList')"> | ||
<i class="fas fa-list-ol"></i> | ||
</button> | ||
<button onclick="insertCheckbox()"> | ||
<i class="fas fa-check-square"></i> | ||
</button> | ||
</div> | ||
<div | ||
id="notepad" | ||
contenteditable="true" | ||
placeholder="Start typing..." | ||
></div> | ||
</div> | ||
<script src="popup.js"></script> | ||
</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,41 @@ | ||
document.addEventListener("DOMContentLoaded", (event) => { | ||
const notepad = document.getElementById("notepad"); | ||
|
||
// Load saved content from chrome.storage | ||
chrome.storage.sync.get(["notepadContent"], function (result) { | ||
if (result.notepadContent) { | ||
notepad.innerHTML = result.notepadContent; | ||
} | ||
}); | ||
|
||
// Save content to chrome.storage on input | ||
notepad.addEventListener("input", () => { | ||
chrome.storage.sync.set({ notepadContent: notepad.innerHTML }); | ||
}); | ||
}); | ||
|
||
// Function to format the selected text | ||
function formatText(command) { | ||
document.execCommand(command, false, null); | ||
} | ||
|
||
// Function to insert a checkbox at the caret position | ||
function insertCheckbox() { | ||
const checkbox = document.createElement("input"); | ||
checkbox.type = "checkbox"; | ||
checkbox.style.marginRight = "5px"; | ||
insertNodeAtCaret(checkbox); | ||
} | ||
|
||
// Helper function to insert a node at the caret position | ||
function insertNodeAtCaret(node) { | ||
let sel = window.getSelection(); | ||
if (sel.rangeCount) { | ||
let range = sel.getRangeAt(0); | ||
range.deleteContents(); | ||
range.insertNode(node); | ||
range.collapse(false); | ||
sel.removeAllRanges(); | ||
sel.addRange(range); | ||
} | ||
} |