diff --git a/.gitignore b/.gitignore deleted file mode 100644 index b512c09..0000000 --- a/.gitignore +++ /dev/null @@ -1 +0,0 @@ -node_modules \ No newline at end of file diff --git a/app.css b/app.css index 1dc7ccd..287a5c5 100644 --- a/app.css +++ b/app.css @@ -341,6 +341,7 @@ dialog { background-color: var(--component-background); border-radius: calc(var(--radius) / 2); line-height: 1.5; + font-size: 0.95rem; color: var(--text-color); } diff --git a/app.html b/app.html index 6a210f6..0b82e75 100644 --- a/app.html +++ b/app.html @@ -171,7 +171,6 @@ - diff --git a/app.js b/app.js index bcf82a0..06e27a6 100644 --- a/app.js +++ b/app.js @@ -5,6 +5,7 @@ import { decodeVariable, downloadAsTextFile, dialog, + autoResizeTextarea, } from "./helper.js"; import { chromeGetData, chromeSetData } from "./chrome.js"; @@ -32,8 +33,6 @@ function loadEventListeners() { const saveTimeout = 500; let typingTimer; - autosize($notes); - $copyToClipboard.addEventListener("click", function () { if ($notes.value.length < 1) { dialog({ @@ -45,7 +44,8 @@ function loadEventListeners() { } copyToClipboard($notes, function () { dialog({ - content: "Copied, you're all set to send it anywhere you want!", + content: + "Copied to clipboard, you're all set to send it anywhere you want.", type: "alert", }); console.log("Copied!"); @@ -70,7 +70,7 @@ function loadEventListeners() { dialog({ content: ` - Are you sure you want to use your template for your notes now? This will override your current notes. + Are you sure you want to use your Notes template now? This will override your current notes. `, confirmCallback: () => { loadNotesTemplate(); @@ -103,8 +103,7 @@ async function loadNotesTemplate() { if (notesTemplate) { $notes.value = decodeVariable(notesTemplate); - autosize.update($notes); - + autoResizeTextarea($notes); saveNotes(); console.log("I won't feel a thing"); @@ -188,7 +187,7 @@ async function restoreSettings() { $notes.value = notesTemplate; $notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length; - autosize.update($notes); + autoResizeTextarea($notes); saveNotes(); // Save currently loaded template as notes return; } @@ -197,7 +196,7 @@ async function restoreSettings() { $notes.value = notes; $notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length; - autosize.update($notes); + autoResizeTextarea($notes); return; } @@ -207,5 +206,5 @@ async function restoreSettings() { $notes.value = notes; $notesCurrentChars.innerHTML = maxNotesChars - $notes.value.length; - autosize.update($notes); + autoResizeTextarea($notes); } diff --git a/helper.js b/helper.js index f74e87b..d410360 100644 --- a/helper.js +++ b/helper.js @@ -188,6 +188,20 @@ const showElement = ($element) => { $element.style.display = ""; }; +const resizeTextareaHandler = (e) => { + const $this = e.target ?? e; + + $this.style.height = `auto`; + $this.style.height = `${$this.scrollHeight}px`; + $this.style.resize = `none`; +}; + +const autoResizeTextarea = ($textarea) => { + resizeTextareaHandler($textarea); + + $textarea.addEventListener("input", resizeTextareaHandler, false); +}; + export { copyToClipboard, getCurrentFullDate, @@ -198,4 +212,5 @@ export { decodeVariable, downloadAsTextFile, dialog, + autoResizeTextarea, }; diff --git a/libs/autosize/autosize.min.js b/libs/autosize/autosize.min.js deleted file mode 100644 index 4d9b4e9..0000000 --- a/libs/autosize/autosize.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! - autosize 4.0.2 - license: MIT - http://www.jacklmoore.com/autosize -*/ -!function(e,t){if("function"==typeof define&&define.amd)define(["module","exports"],t);else if("undefined"!=typeof exports)t(module,exports);else{var n={exports:{}};t(n,n.exports),e.autosize=n.exports}}(this,function(e,t){"use strict";var n,o,p="function"==typeof Map?new Map:(n=[],o=[],{has:function(e){return-1Settings
- +