Skip to content

Commit

Permalink
Merge pull request #27 from allen505/fix-4-editable-title
Browse files Browse the repository at this point in the history
Fixing editable Title for Firefox
  • Loading branch information
allen505 authored Feb 22, 2023
2 parents 59b9c4a + d3bf10c commit 52efa1c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 2,
"name": "Save for later",
"version": "1.2",
"version": "1.2.1",

"description": "Save tabs in window to be used later",

Expand Down
1 change: 1 addition & 0 deletions popup/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ body {
text-align: left;
float: left;
flex-grow: 1;
white-space: pre-wrap;
}

.iconBtn {
Expand Down
18 changes: 17 additions & 1 deletion popup/warehouse.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ function createList(storeObj) {
event.preventDefault();
handleTitleUpdate(obj, saveTitle)
}
if (event.key === ' ') {
event.preventDefault();
insertTextAtCaret(' ');
}
})

saveTitle.addEventListener('focusout', () => {
Expand Down Expand Up @@ -178,7 +182,7 @@ function validateAndUpdateTitle(obj, newTitleText) {
}

function santizeTitleName(titleText) {
const maxTitleLength = 29
const maxTitleLength = 40
if (titleText.length >= maxTitleLength) {
return titleText.substring(0, maxTitleLength);
}
Expand Down Expand Up @@ -230,6 +234,18 @@ function validateAndOpenSave(obj) {
});
}

// Reference: https://stackoverflow.com/a/75505941/4688365
function insertTextAtCaret(text) {
var sel, range;
sel = window.getSelection();
if (sel && sel.getRangeAt && sel.rangeCount) {
range = sel.getRangeAt(0);
range.deleteContents();
range.insertNode(document.createTextNode(text));
range.collapse();
}
}

async function storeIt(tabs) {
// storeIt takes only the required data from what is provided by the browser and
// stores it into the storage.local
Expand Down

0 comments on commit 52efa1c

Please sign in to comment.