Discussing about the impact on scripting and theming #8257
Replies: 2 comments
-
|
Previously, I had a script to change the font for the entire page, and everything worked fine when using I had to revert to using Perhaps it would be worth considering removing the startup delay of frontendStartup, or distinguishing it into beforeFrontendStartup and afterFrontendStartup. |
Beta Was this translation helpful? Give feedback.
-
|
My script has been affected, but in fact, I suspect that the script running previously was not as designed. api.addButtonToToolbar({
title: 'import',
icon: 'import',
shortcut: 'ctrl+i',
action: async function() {
const noteId = await api.getActiveContextNote().noteId
await api.runOnBackend((noteId) => {
const {dialog} = require('electron')
const {readFileSync} = require('fs')
const {basename,extname} = require('path')
const mimeTypes = require('mime-types')
// extensions missing in mime-db
const EXTENSION_TO_MIME = {
".c": "text/x-csrc",
".cs": "text/x-csharp",
".clj": "text/x-clojure",
".erl": "text/x-erlang",
".hrl": "text/x-erlang",
".feature": "text/x-feature",
".go": "text/x-go",
".groovy": "text/x-groovy",
".hs": "text/x-haskell",
".lhs": "text/x-haskell",
".http": "message/http",
".kt": "text/x-kotlin",
".m": "text/x-objectivec",
".py": "text/x-python",
".rb": "text/x-ruby",
".scala": "text/x-scala",
".swift": "text/x-swift"
}
function getMime(fileName) {
if (fileName.toLowerCase() === 'dockerfile') {
return "text/x-dockerfile";
}
const ext = extname(fileName).toLowerCase();
if (ext in EXTENSION_TO_MIME) {
return EXTENSION_TO_MIME[ext];
}
return mimeTypes.lookup(fileName);
}
const files=dialog.showOpenDialogSync({ properties: ['openFile', 'multiSelections'] })
if(undefined!== files&&undefined!==noteId ){
for (const file of files){
const data=readFileSync(file)
const originalName=basename(file)
const {note} = api.createNewNote({
parentNoteId:noteId,
title:originalName,
content:data,
type:'file',
mime:getMime(originalName)
})
note.addLabel("originalFileName", originalName);
}
}
return files;
},[noteId])
await api.waitUntilSynced()
api.reloadNotes([noteId]);
}
}); |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I'm writing this post for us to discuss how scripting and themes was impacted by our changes in the past year. I would appreciate concrete examples, so that we can see how we can improve the resilience of scripting to changes and to improve the documentation.
Let me know your thoughts.
Beta Was this translation helpful? Give feedback.
All reactions