Better Notes Mod
-
This is how I tried to fix it. Not understanding why the consts, I've used some vars instead, and conditioned them of being not null.
Also the count of words is better replaced with a regexp to find any count of spaces followed by any count of non whitespace chars.function updateWordCount(){ const wordcountspan = document.querySelector("#note-word-count"); const notetextarea = document.querySelector("#notes-panel > div > div > textarea"); if(wordcountspan === null || notetextarea===null){ wordcountspan.textContent = "(check word count)"; return; } const notetext = notetextarea.value; const characters = notetext.length; var matchspace=notetext.match(/ *\S+/g); var words = 0; var lines = 0; if(matchspace === null) { if (characters>0) { words = 1; } } else { words = matchspace.length; } matchspace=notetext.match(/\n/g); if(matchspace === null) { if (characters>0) { lines = 1; } } else { lines = matchspace.length + 1; } const message = "C: "+characters+" W: "+words+" L: "+lines; wordcountspan.textContent = message; }
-
I've updated the original post with some fixes, and it can now auto-update the counting rather than relying on a click.
-
@lonm that's better, one more change to fix the lines counter
const lines = lineMatches ? lineMatches.length+1 : (characters==0 ? 0 : 1);
this way it's 0 if you delete all text, at least 1 for at least 1 char, and (number of CR found) +1, else it would be counting 1 even for 2 lines
For my convenience I changed the
stroke="#321"
to
stroke="#777"
so the icon is visible in both light and dark themes. I've no idea how to set it to the actual theme colors -
@ian-coog Good call on the line counting. I've also updated it to use the browser theme colour variables.
-
@lonm Nice, now that's perfect IMHO. It goes in my CustomCSS pack.
-
Thanks you. Awesome mod dude
-
I have updated to include new features - such as a font toggle and a word wrap toggle.
-
awesome mod. thanks man
-
I have updated the mod with a new version, the first post in this topic has all the details.
Main new feature: Full page dual-column editor and previewer.
-
@lonm The editor interface seems to be messed up in Vivaldi 2.0.1309.37 Stable. Moreover, once I open the editor tab in a window, even after I close the editor tab and close and re-open the notes panel, note contents do not show up in the notes panel anymore, and I have to open a new window to get the notes panel working properly again.
-
@valiowk I've noticed some problems in 2.1 snapshots as well. I'll have to have another look at this.
-
I've pushed an update that fixes an issue where the notes tab wouldn't open after you close it.
-
Update 7: You can now drag images onto the attachment icon to add an attachment quickly.
-
I'm still encountering problems with the editor interface: see the screenshot. Any idea where the problem lies? Dragging image onto the attachment icon doesn't seem to work for me after replacing my files with your latest version.
-
- Have you definitely copied the
.css
files as well as the.js
files? - If you open the browser console (
vivaldi://inspect
> Apps > Inspect Vivaldi > Console), do you see any messages starting with "BN"?
- Have you definitely copied the
-
@LonM I definitely copied the .css as well as the .js files. I don't see any messages starting with "BN" if I open the browser console.
-
@valiowk It looks as though the
common.css
file isn't loading from the browser. When you installed the mod, where did you put it? I expect the structure of the vivaldi folder after installing the mod to look something like this:vivaldi āāā background-bundle.js āāā background-common-bundle.js āāā browser.html āāā bundle.js āāā style/ āĀ Ā āāā common.css āĀ Ā āāā common.js āāā user_modfiles/ āĀ Ā āāā betterNotes.css āĀ Ā āāā betterNotesEditor.css āĀ Ā āāā betterNotesEditor.html āĀ Ā āāā betterNotesEditor.js āĀ Ā āāā betterNotesEditor.png āĀ Ā āāā betterNotes.js āāā vendor-bundle.js
I've omitted a few files and folders for clarity
Does this match how you have mods installed?
-
@LonM Yes, that's how I have the mods installed. I intentionally set the structure of how I have this mod installed to match yours so that I don't need to edit the files after downloading them whenever they are updated.
-
@valiowk Do you have any extensions installed which might interfere with loading of styles? I don't think that should be a problem, but you never know.
-
@LonM I disabled all extensions to check and the problem remains.