Comments (9)
At the time handleNewNoteHeadlineHook
is called the note doesn't exist yet.
Just return the filename you want every time in handleNoteTextFileNameHook
or is something preventing you from doing that?
from scripts.
You could for example check the created date: https://www.qownnotes.org/scripting/classes.html#note
from scripts.
So my handleNoteTextFileNameHook
function would have two code paths? In the first instance, I assume there is not yet a file creation date, and so I calculate my string as before using the current time. Subsequently, my handleNoteTextFileNameHook
would find that there is a file, and file creation date, and would use that. Does that sound right? (By the way, when I tried a script.log
containing note.fileCreated.toISOString()
I get "RangeError: Invalid Date out of range" in both scenarios.)
My hope had been that the NoteApi
parameter of handleNewNoteHeadlineHook
would allow access to a boolean indicating that there is already a file name associated with this note. Alternatively, another hook such as handleNewNoteHeadlineHook
, say handleNewNoteHeadlineFilenameHook
, could return both a headline and a filename as a simple pair object.
from scripts.
Funny, it seems like fileCreated
will only be set if the note tree is reloaded. But you can also check the fileLastModified
. But use handleNoteTextFileNameHook
.
from scripts.
I edited my last comment: my function names were mixed up. I'll try fileLastModified
.
from scripts.
I added the following at the start of my handleNoteTextFileNameHook
function, and it seems to be working now. Thanks for the advice.
if (!isNaN(note.fileLastModified)) {
return "";
}
from scripts.
Great, and I will fix the fileCreated
.
from scripts.
20.12.1
- the
fileCreated
date will now also be set for new notes before the note folder is reloaded
from scripts.
There now is a new release, could you please test it and report if it works for you?
from scripts.
Related Issues (20)
- [SUPPORT] Stuck trying to get Backlinks script to work HOT 4
- [SUPPORT] Mermaid diagrams script: theme configuration for sequenceDiagram HOT 6
- [BUG] Latex Math v0.0.6 script doesn't update pictures when color style is changed HOT 7
- [BUG] Toggle checkbox - checkbox where added in wrong place when autocreated from list HOT 5
- [FEATURE] Add video display support HOT 3
- [BUG] The "YAML nested tags" script breaks formatting and causing text lost in preview HOT 4
- [BUG] "exportFolder is not defined" in export-notes-as-website HOT 7
- [BUG] A Wiki Link to a note under notes sub-folder gives pop up "Note was not found" even if it exists HOT 4
- [SUPPORT] HOT 11
- [SUPPORT] HOT 2
- [SUPPORT] LateX Math results in very aliased images HOT 8
- adding favorite note script results with error " Expected a qualified name id"[BUG] HOT 10
- [SUPPORT] HOT 7
- [BUG] can't follow [[wiki linked]] file links that have spaces HOT 2
- [BUG] Scripts "export note as website" not working properly on Windows HOT 7
- [BUG] export note using pandoc not working on windows HOT 2
- [BUG] Backlinks doesn't support setext headers for title HOT 6
- [BUG] LaTeX math script generates empty icons instead of images HOT 3
- [BUG] Backlinks on Windows HOT 8
- [BUG] meeting-note filename when headline prefix is empty HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from scripts.