mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
always use template strings instead of string concatenation
This commit is contained in:
parent
ea006993f6
commit
1b24276a4a
@ -9,7 +9,7 @@ sqlInit.dbReady.then(async () => {
|
|||||||
const resp = await backupService.anonymize();
|
const resp = await backupService.anonymize();
|
||||||
|
|
||||||
if (resp.success) {
|
if (resp.success) {
|
||||||
console.log("Anonymized file has been saved to: " + resp.anonymizedFilePath);
|
console.log(`Anonymized file has been saved to: ${resp.anonymizedFilePath}`);
|
||||||
|
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
} else {
|
} else {
|
||||||
|
@ -66,12 +66,12 @@ const sessionParser = session({
|
|||||||
name: 'trilium.sid',
|
name: 'trilium.sid',
|
||||||
store: new FileStore({
|
store: new FileStore({
|
||||||
ttl: 30 * 24 * 3600,
|
ttl: 30 * 24 * 3600,
|
||||||
path: dataDir.TRILIUM_DATA_DIR + '/sessions'
|
path: `${dataDir.TRILIUM_DATA_DIR}/sessions`
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
app.use(sessionParser);
|
app.use(sessionParser);
|
||||||
|
|
||||||
app.use(favicon(__dirname + '/../images/app-icons/win/icon.ico'));
|
app.use(favicon(`${__dirname}/../images/app-icons/win/icon.ico`));
|
||||||
|
|
||||||
require('./routes/routes').register(app);
|
require('./routes/routes').register(app);
|
||||||
|
|
||||||
@ -91,7 +91,7 @@ app.use((err, req, res, next) => {
|
|||||||
|
|
||||||
// catch 404 and forward to error handler
|
// catch 404 and forward to error handler
|
||||||
app.use((req, res, next) => {
|
app.use((req, res, next) => {
|
||||||
const err = new Error('Router not found for request ' + req.url);
|
const err = new Error(`Router not found for request ${req.url}`);
|
||||||
err.status = 404;
|
err.status = 404;
|
||||||
next(err);
|
next(err);
|
||||||
});
|
});
|
||||||
|
@ -75,7 +75,7 @@ function getNoteTitle(childNoteId, parentNoteId) {
|
|||||||
|
|
||||||
const branch = parentNote ? becca.getBranchFromChildAndParent(childNote.noteId, parentNote.noteId) : null;
|
const branch = parentNote ? becca.getBranchFromChildAndParent(childNote.noteId, parentNote.noteId) : null;
|
||||||
|
|
||||||
return ((branch && branch.prefix) ? `${branch.prefix} - ` : '') + title;
|
return `${(branch && branch.prefix) ? `${branch.prefix} - ` : ''}${title}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoteTitleArrayForPath(notePathArray) {
|
function getNoteTitleArrayForPath(notePathArray) {
|
||||||
|
@ -31,7 +31,7 @@ class AbstractEntity {
|
|||||||
let contentToHash = "";
|
let contentToHash = "";
|
||||||
|
|
||||||
for (const propertyName of this.constructor.hashedProperties) {
|
for (const propertyName of this.constructor.hashedProperties) {
|
||||||
contentToHash += "|" + this[propertyName];
|
contentToHash += `|${this[propertyName]}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isDeleted) {
|
if (isDeleted) {
|
||||||
|
@ -185,7 +185,7 @@ class Branch extends AbstractEntity {
|
|||||||
|
|
||||||
// first delete children and then parent - this will show up better in recent changes
|
// first delete children and then parent - this will show up better in recent changes
|
||||||
|
|
||||||
log.info("Deleting note " + note.noteId);
|
log.info(`Deleting note ${note.noteId}`);
|
||||||
|
|
||||||
this.becca.notes[note.noteId].isBeingDeleted = true;
|
this.becca.notes[note.noteId].isBeingDeleted = true;
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ class Note extends AbstractEntity {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Cannot find note content for noteId=" + this.noteId);
|
throw new Error(`Cannot find note content for noteId=${this.noteId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,7 +304,7 @@ class Note extends AbstractEntity {
|
|||||||
|
|
||||||
sql.upsert("note_contents", "noteId", pojo);
|
sql.upsert("note_contents", "noteId", pojo);
|
||||||
|
|
||||||
const hash = utils.hash(this.noteId + "|" + pojo.content.toString());
|
const hash = utils.hash(`${this.noteId}|${pojo.content.toString()}`);
|
||||||
|
|
||||||
entityChangesService.addEntityChange({
|
entityChangesService.addEntityChange({
|
||||||
entityName: 'note_contents',
|
entityName: 'note_contents',
|
||||||
@ -739,22 +739,22 @@ class Note extends AbstractEntity {
|
|||||||
*/
|
*/
|
||||||
getFlatText() {
|
getFlatText() {
|
||||||
if (!this.flatTextCache) {
|
if (!this.flatTextCache) {
|
||||||
this.flatTextCache = this.noteId + ' ' + this.type + ' ' + this.mime + ' ';
|
this.flatTextCache = `${this.noteId} ${this.type} ${this.mime} `;
|
||||||
|
|
||||||
for (const branch of this.parentBranches) {
|
for (const branch of this.parentBranches) {
|
||||||
if (branch.prefix) {
|
if (branch.prefix) {
|
||||||
this.flatTextCache += branch.prefix + ' ';
|
this.flatTextCache += `${branch.prefix} `;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flatTextCache += this.title + ' ';
|
this.flatTextCache += `${this.title} `;
|
||||||
|
|
||||||
for (const attr of this.getAttributes()) {
|
for (const attr of this.getAttributes()) {
|
||||||
// it's best to use space as separator since spaces are filtered from the search string by the tokenization into words
|
// it's best to use space as separator since spaces are filtered from the search string by the tokenization into words
|
||||||
this.flatTextCache += (attr.type === 'label' ? '#' : '~') + attr.name;
|
this.flatTextCache += `${attr.type === 'label' ? '#' : '~'}${attr.name}`;
|
||||||
|
|
||||||
if (attr.value) {
|
if (attr.value) {
|
||||||
this.flatTextCache += '=' + attr.value;
|
this.flatTextCache += `=${attr.value}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.flatTextCache += ' ';
|
this.flatTextCache += ' ';
|
||||||
|
@ -81,7 +81,7 @@ class NoteRevision extends AbstractEntity {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Cannot find note revision content for noteRevisionId=" + this.noteRevisionId);
|
throw new Error(`Cannot find note revision content for noteRevisionId=${this.noteRevisionId}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,7 +124,7 @@ class NoteRevision extends AbstractEntity {
|
|||||||
|
|
||||||
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
|
sql.upsert("note_revision_contents", "noteRevisionId", pojo);
|
||||||
|
|
||||||
const hash = utils.hash(this.noteRevisionId + "|" + pojo.content.toString());
|
const hash = utils.hash(`${this.noteRevisionId}|${pojo.content.toString()}`);
|
||||||
|
|
||||||
entityChangesService.addEntityChange({
|
entityChangesService.addEntityChange({
|
||||||
entityName: 'note_revision_contents',
|
entityName: 'note_revision_contents',
|
||||||
|
@ -66,7 +66,7 @@ function isNoteType(obj) {
|
|||||||
const noteTypes = noteTypeService.getNoteTypeNames();
|
const noteTypes = noteTypeService.getNoteTypeNames();
|
||||||
|
|
||||||
if (!noteTypes.includes(obj)) {
|
if (!noteTypes.includes(obj)) {
|
||||||
return `'${obj}' is not a valid note type, allowed types are: ` + noteTypes.join(", ");
|
return `'${obj}' is not a valid note type, allowed types are: ${noteTypes.join(", ")}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -96,7 +96,7 @@ class AppContext extends Component {
|
|||||||
/** @returns {Promise} */
|
/** @returns {Promise} */
|
||||||
triggerCommand(name, data = {}) {
|
triggerCommand(name, data = {}) {
|
||||||
for (const executor of this.components) {
|
for (const executor of this.components) {
|
||||||
const fun = executor[name + "Command"];
|
const fun = executor[`${name}Command`];
|
||||||
|
|
||||||
if (fun) {
|
if (fun) {
|
||||||
return executor.callMethod(fun, data);
|
return executor.callMethod(fun, data);
|
||||||
|
@ -13,7 +13,7 @@ import utils from '../services/utils.js';
|
|||||||
*/
|
*/
|
||||||
export default class Component {
|
export default class Component {
|
||||||
constructor() {
|
constructor() {
|
||||||
this.componentId = this.sanitizedClassName + '-' + utils.randomString(8);
|
this.componentId = `${this.sanitizedClassName}-${utils.randomString(8)}`;
|
||||||
/** @type Component[] */
|
/** @type Component[] */
|
||||||
this.children = [];
|
this.children = [];
|
||||||
this.initialized = null;
|
this.initialized = null;
|
||||||
@ -44,8 +44,8 @@ export default class Component {
|
|||||||
handleEvent(name, data) {
|
handleEvent(name, data) {
|
||||||
try {
|
try {
|
||||||
const callMethodPromise = this.initialized
|
const callMethodPromise = this.initialized
|
||||||
? this.initialized.then(() => this.callMethod(this[name + 'Event'], data))
|
? this.initialized.then(() => this.callMethod(this[`${name}Event`], data))
|
||||||
: this.callMethod(this[name + 'Event'], data);
|
: this.callMethod(this[`${name}Event`], data);
|
||||||
|
|
||||||
const childrenPromise = this.handleEventInChildren(name, data);
|
const childrenPromise = this.handleEventInChildren(name, data);
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ export default class Component {
|
|||||||
|
|
||||||
/** @returns {Promise} */
|
/** @returns {Promise} */
|
||||||
triggerCommand(name, data = {}) {
|
triggerCommand(name, data = {}) {
|
||||||
const fun = this[name + 'Command'];
|
const fun = this[`${name}Command`];
|
||||||
|
|
||||||
if (fun) {
|
if (fun) {
|
||||||
return this.callMethod(fun, data);
|
return this.callMethod(fun, data);
|
||||||
|
@ -150,7 +150,7 @@ export default class Entrypoints extends Component {
|
|||||||
ipcRenderer.send('create-extra-window', {notePath, hoistedNoteId});
|
ipcRenderer.send('create-extra-window', {notePath, hoistedNoteId});
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
const url = window.location.protocol + '//' + window.location.host + window.location.pathname + '?extra=1#' + notePath;
|
const url = `${window.location.protocol}//${window.location.host}${window.location.pathname}?extra=1#${notePath}`;
|
||||||
|
|
||||||
window.open(url, '', 'width=1000,height=800');
|
window.open(url, '', 'width=1000,height=800');
|
||||||
}
|
}
|
||||||
@ -172,12 +172,12 @@ export default class Entrypoints extends Component {
|
|||||||
if (note.mime.endsWith("env=frontend")) {
|
if (note.mime.endsWith("env=frontend")) {
|
||||||
await bundleService.getAndExecuteBundle(note.noteId);
|
await bundleService.getAndExecuteBundle(note.noteId);
|
||||||
} else if (note.mime.endsWith("env=backend")) {
|
} else if (note.mime.endsWith("env=backend")) {
|
||||||
await server.post('script/run/' + note.noteId);
|
await server.post(`script/run/${note.noteId}`);
|
||||||
} else if (note.mime === 'text/x-sqlite;schema=trilium') {
|
} else if (note.mime === 'text/x-sqlite;schema=trilium') {
|
||||||
const resp = await server.post("sql/execute/" + note.noteId);
|
const resp = await server.post(`sql/execute/${note.noteId}`);
|
||||||
|
|
||||||
if (!resp.success) {
|
if (!resp.success) {
|
||||||
toastService.showError("Error occurred while executing SQL query: " + resp.message);
|
toastService.showError(`Error occurred while executing SQL query: ${resp.message}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results});
|
await appContext.triggerEvent('sqlQueryResults', {ntxId: ntxId, results: resp.results});
|
||||||
|
@ -126,7 +126,7 @@ export default class TabManager extends Component {
|
|||||||
|
|
||||||
if (window.history.length === 0 // first history entry
|
if (window.history.length === 0 // first history entry
|
||||||
|| (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) {
|
|| (activeNoteContext && activeNoteContext.notePath !== treeService.getHashValueFromAddress()[0])) {
|
||||||
const url = '#' + (activeNoteContext.notePath || "") + "-" + activeNoteContext.ntxId;
|
const url = `#${activeNoteContext.notePath || ""}-${activeNoteContext.ntxId}`;
|
||||||
|
|
||||||
// using pushState instead of directly modifying document.location because it does not trigger hashchange
|
// using pushState instead of directly modifying document.location because it does not trigger hashchange
|
||||||
window.history.pushState(null, "", url);
|
window.history.pushState(null, "", url);
|
||||||
|
@ -112,7 +112,7 @@ if (utils.isElectron()) {
|
|||||||
|
|
||||||
if (hasText) {
|
if (hasText) {
|
||||||
const shortenedSelection = params.selectionText.length > 15
|
const shortenedSelection = params.selectionText.length > 15
|
||||||
? (params.selectionText.substr(0, 13) + "…")
|
? (`${params.selectionText.substr(0, 13)}…`)
|
||||||
: params.selectionText;
|
: params.selectionText;
|
||||||
|
|
||||||
items.push({
|
items.push({
|
||||||
|
@ -119,7 +119,7 @@ class NoteShort {
|
|||||||
|
|
||||||
async getContent() {
|
async getContent() {
|
||||||
// we're not caching content since these objects are in froca and as such pretty long lived
|
// we're not caching content since these objects are in froca and as such pretty long lived
|
||||||
const note = await server.get("notes/" + this.noteId);
|
const note = await server.get(`notes/${this.noteId}`);
|
||||||
|
|
||||||
return note.content;
|
return note.content;
|
||||||
}
|
}
|
||||||
@ -813,7 +813,7 @@ class NoteShort {
|
|||||||
return await bundleService.getAndExecuteBundle(this.noteId);
|
return await bundleService.getAndExecuteBundle(this.noteId);
|
||||||
}
|
}
|
||||||
else if (env === "backend") {
|
else if (env === "backend") {
|
||||||
return await server.post('script/run/' + this.noteId);
|
return await server.post(`script/run/${this.noteId}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error(`Unrecognized env type ${env} for note ${this.noteId}`);
|
throw new Error(`Unrecognized env type ${env} for note ${this.noteId}`);
|
||||||
|
@ -52,7 +52,7 @@ async function initLabelValueAutocomplete({ $el, open, nameCallback }) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const attributeValues = (await server.get('attributes/values/' + encodeURIComponent(attributeName)))
|
const attributeValues = (await server.get(`attributes/values/${encodeURIComponent(attributeName)}`))
|
||||||
.map(attribute => ({ value: attribute }));
|
.map(attribute => ({ value: attribute }));
|
||||||
|
|
||||||
if (attributeValues.length === 0) {
|
if (attributeValues.length === 0) {
|
||||||
|
@ -125,9 +125,7 @@ function parse(tokens, str, allowEmptyRelations = false) {
|
|||||||
startIndex = Math.max(0, startIndex - 20);
|
startIndex = Math.max(0, startIndex - 20);
|
||||||
endIndex = Math.min(str.length, endIndex + 20);
|
endIndex = Math.min(str.length, endIndex + 20);
|
||||||
|
|
||||||
return '"' + (startIndex !== 0 ? "..." : "")
|
return `"${startIndex !== 0 ? "..." : ""}${str.substr(startIndex, endIndex - startIndex)}${endIndex !== str.length ? "..." : ""}"`;
|
||||||
+ str.substr(startIndex, endIndex - startIndex)
|
|
||||||
+ (endIndex !== str.length ? "..." : "") + '"';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < tokens.length; i++) {
|
for (let i = 0; i < tokens.length; i++) {
|
||||||
|
@ -6,7 +6,7 @@ async function renderAttribute(attribute, renderIsInheritable) {
|
|||||||
const $attr = $("<span>");
|
const $attr = $("<span>");
|
||||||
|
|
||||||
if (attribute.type === 'label') {
|
if (attribute.type === 'label') {
|
||||||
$attr.append(document.createTextNode('#' + attribute.name + isInheritable));
|
$attr.append(document.createTextNode(`#${attribute.name}${isInheritable}`));
|
||||||
|
|
||||||
if (attribute.value) {
|
if (attribute.value) {
|
||||||
$attr.append('=');
|
$attr.append('=');
|
||||||
@ -19,11 +19,11 @@ async function renderAttribute(attribute, renderIsInheritable) {
|
|||||||
|
|
||||||
// when the relation has just been created then it might not have a value
|
// when the relation has just been created then it might not have a value
|
||||||
if (attribute.value) {
|
if (attribute.value) {
|
||||||
$attr.append(document.createTextNode('~' + attribute.name + isInheritable + "="));
|
$attr.append(document.createTextNode(`~${attribute.name}${isInheritable}=`));
|
||||||
$attr.append(await createNoteLink(attribute.value));
|
$attr.append(await createNoteLink(attribute.value));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ws.logError("Unknown attr type: " + attribute.type);
|
ws.logError(`Unknown attr type: ${attribute.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $attr;
|
return $attr;
|
||||||
@ -34,16 +34,16 @@ function formatValue(val) {
|
|||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
else if (!val.includes('"')) {
|
else if (!val.includes('"')) {
|
||||||
return '"' + val + '"';
|
return `"${val}"`;
|
||||||
}
|
}
|
||||||
else if (!val.includes("'")) {
|
else if (!val.includes("'")) {
|
||||||
return "'" + val + "'";
|
return `'${val}'`;
|
||||||
}
|
}
|
||||||
else if (!val.includes("`")) {
|
else if (!val.includes("`")) {
|
||||||
return "`" + val + "`";
|
return `\`${val}\``;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return '"' + val.replace(/"/g, '\\"') + '"';
|
return `"${val.replace(/"/g, '\\"')}"`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ async function createNoteLink(noteId) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $("<a>", {
|
return $("<a>", {
|
||||||
href: '#root/' + noteId,
|
href: `#root/${noteId}`,
|
||||||
class: 'reference-link',
|
class: 'reference-link',
|
||||||
'data-note-path': noteId
|
'data-note-path': noteId
|
||||||
})
|
})
|
||||||
|
@ -116,10 +116,10 @@ async function deleteNotes(branchIdsToDelete, forceDeleteAllClones = false) {
|
|||||||
const branch = froca.getBranch(branchIdToDelete);
|
const branch = froca.getBranch(branchIdToDelete);
|
||||||
|
|
||||||
if (deleteAllClones) {
|
if (deleteAllClones) {
|
||||||
await server.remove(`notes/${branch.noteId}` + query);
|
await server.remove(`notes/${branch.noteId}${query}`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
await server.remove(`branches/${branchIdToDelete}` + query);
|
await server.remove(`branches/${branchIdToDelete}${query}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,7 +186,7 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.closePersistent(message.taskId);
|
toastService.closePersistent(message.taskId);
|
||||||
toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
} else if (message.type === 'taskProgressCount') {
|
} else if (message.type === 'taskProgressCount') {
|
||||||
toastService.showPersistent(makeToast(message.taskId, "Delete notes in progress: " + message.progressCount));
|
toastService.showPersistent(makeToast(message.taskId, `Delete notes in progress: ${message.progressCount}`));
|
||||||
} else if (message.type === 'taskSucceeded') {
|
} else if (message.type === 'taskSucceeded') {
|
||||||
const toast = makeToast(message.taskId, "Delete finished successfully.");
|
const toast = makeToast(message.taskId, "Delete finished successfully.");
|
||||||
toast.closeAfter = 5000;
|
toast.closeAfter = 5000;
|
||||||
@ -204,7 +204,7 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.closePersistent(message.taskId);
|
toastService.closePersistent(message.taskId);
|
||||||
toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
} else if (message.type === 'taskProgressCount') {
|
} else if (message.type === 'taskProgressCount') {
|
||||||
toastService.showPersistent(makeToast(message.taskId, "Undeleting notes in progress: " + message.progressCount));
|
toastService.showPersistent(makeToast(message.taskId, `Undeleting notes in progress: ${message.progressCount}`));
|
||||||
} else if (message.type === 'taskSucceeded') {
|
} else if (message.type === 'taskSucceeded') {
|
||||||
const toast = makeToast(message.taskId, "Undeleting notes finished successfully.");
|
const toast = makeToast(message.taskId, "Undeleting notes finished successfully.");
|
||||||
toast.closeAfter = 5000;
|
toast.closeAfter = 5000;
|
||||||
@ -235,7 +235,7 @@ async function cloneNoteToNote(childNoteId, parentNoteId, prefix) {
|
|||||||
|
|
||||||
// beware that first arg is noteId and second is branchId!
|
// beware that first arg is noteId and second is branchId!
|
||||||
async function cloneNoteAfter(noteId, afterBranchId) {
|
async function cloneNoteAfter(noteId, afterBranchId) {
|
||||||
const resp = await server.put('notes/' + noteId + '/clone-after/' + afterBranchId);
|
const resp = await server.put(`notes/${noteId}/clone-after/${afterBranchId}`);
|
||||||
|
|
||||||
if (!resp.success) {
|
if (!resp.success) {
|
||||||
toastService.showError(resp.message);
|
toastService.showError(resp.message);
|
||||||
|
@ -5,7 +5,7 @@ import froca from "./froca.js";
|
|||||||
import utils from "./utils.js";
|
import utils from "./utils.js";
|
||||||
|
|
||||||
async function getAndExecuteBundle(noteId, originEntity = null) {
|
async function getAndExecuteBundle(noteId, originEntity = null) {
|
||||||
const bundle = await server.get('script/bundle/' + noteId);
|
const bundle = await server.get(`script/bundle/${noteId}`);
|
||||||
|
|
||||||
return await executeBundle(bundle, originEntity);
|
return await executeBundle(bundle, originEntity);
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,7 @@ async function pasteAfter(afterBranchId) {
|
|||||||
// copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places
|
// copy will keep clipboardBranchIds and clipboardMode so it's possible to paste into multiple places
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastService.throwError("Unrecognized clipboard mode=" + clipboardMode);
|
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,7 +57,7 @@ async function pasteInto(parentBranchId) {
|
|||||||
// copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
|
// copy will keep clipboardBranchIds and clipboardMode, so it's possible to paste into multiple places
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastService.throwError("Unrecognized clipboard mode=" + clipboardMode);
|
toastService.throwError(`Unrecognized clipboard mode=${clipboardMode}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ async function copy(branchIds) {
|
|||||||
const links = [];
|
const links = [];
|
||||||
|
|
||||||
for (const branch of froca.getBranches(clipboardBranchIds)) {
|
for (const branch of froca.getBranches(clipboardBranchIds)) {
|
||||||
const $link = await linkService.createNoteLink(branch.parentNoteId + '/' + branch.noteId, { referenceLink: true });
|
const $link = await linkService.createNoteLink(`${branch.parentNoteId}/${branch.noteId}`, { referenceLink: true });
|
||||||
links.push($link[0].outerHTML);
|
links.push($link[0].outerHTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,7 +11,7 @@ function createClassForColor(color) {
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
const className = 'color-' + normalizedColorName;
|
const className = `color-${normalizedColorName}`;
|
||||||
|
|
||||||
if (!registeredClasses.has(className)) {
|
if (!registeredClasses.has(className)) {
|
||||||
$("head").append(`<style>.${className} { color: ${color} !important; }</style>`);
|
$("head").append(`<style>.${className} { color: ${color} !important; }</style>`);
|
||||||
|
@ -4,7 +4,7 @@ import ws from "./ws.js";
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async function getInboxNote() {
|
async function getInboxNote() {
|
||||||
const note = await server.get('special-notes/inbox/' + dayjs().format("YYYY-MM-DD"), "date-note");
|
const note = await server.get(`special-notes/inbox/${dayjs().format("YYYY-MM-DD")}`, "date-note");
|
||||||
|
|
||||||
return await froca.getNote(note.noteId);
|
return await froca.getNote(note.noteId);
|
||||||
}
|
}
|
||||||
@ -16,7 +16,7 @@ async function getTodayNote() {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async function getDayNote(date) {
|
async function getDayNote(date) {
|
||||||
const note = await server.get('special-notes/days/' + date, "date-note");
|
const note = await server.get(`special-notes/days/${date}`, "date-note");
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
@ -25,7 +25,7 @@ async function getDayNote(date) {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async function getWeekNote(date) {
|
async function getWeekNote(date) {
|
||||||
const note = await server.get('special-notes/weeks/' + date, "date-note");
|
const note = await server.get(`special-notes/weeks/${date}`, "date-note");
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
@ -34,7 +34,7 @@ async function getWeekNote(date) {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async function getMonthNote(month) {
|
async function getMonthNote(month) {
|
||||||
const note = await server.get('special-notes/months/' + month, "date-note");
|
const note = await server.get(`special-notes/months/${month}`, "date-note");
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ async function getMonthNote(month) {
|
|||||||
|
|
||||||
/** @returns {NoteShort} */
|
/** @returns {NoteShort} */
|
||||||
async function getYearNote(year) {
|
async function getYearNote(year) {
|
||||||
const note = await server.get('special-notes/years/' + year, "date-note");
|
const note = await server.get(`special-notes/years/${year}`, "date-note");
|
||||||
|
|
||||||
await ws.waitForMaxKnownEntityChangeId();
|
await ws.waitForMaxKnownEntityChangeId();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ class Froca {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async loadSubTree(subTreeNoteId) {
|
async loadSubTree(subTreeNoteId) {
|
||||||
const resp = await server.get('tree?subTreeNoteId=' + subTreeNoteId);
|
const resp = await server.get(`tree?subTreeNoteId=${subTreeNoteId}`);
|
||||||
|
|
||||||
this.addResp(resp);
|
this.addResp(resp);
|
||||||
|
|
||||||
@ -176,7 +176,7 @@ class Froca {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const {searchResultNoteIds, highlightedTokens, error} = await server.get('search-note/' + note.noteId);
|
const {searchResultNoteIds, highlightedTokens, error} = await server.get(`search-note/${note.noteId}`);
|
||||||
|
|
||||||
if (!Array.isArray(searchResultNoteIds)) {
|
if (!Array.isArray(searchResultNoteIds)) {
|
||||||
throw new Error(`Search note '${note.noteId}' failed: ${searchResultNoteIds}`);
|
throw new Error(`Search note '${note.noteId}' failed: ${searchResultNoteIds}`);
|
||||||
@ -192,7 +192,7 @@ class Froca {
|
|||||||
|
|
||||||
searchResultNoteIds.forEach((resultNoteId, index) => branches.push({
|
searchResultNoteIds.forEach((resultNoteId, index) => branches.push({
|
||||||
// branchId should be repeatable since sometimes we reload some notes without rerendering the tree
|
// branchId should be repeatable since sometimes we reload some notes without rerendering the tree
|
||||||
branchId: "virt-" + note.noteId + '-' + resultNoteId,
|
branchId: `virt-${note.noteId}-${resultNoteId}`,
|
||||||
noteId: resultNoteId,
|
noteId: resultNoteId,
|
||||||
parentNoteId: note.noteId,
|
parentNoteId: note.noteId,
|
||||||
notePosition: (index + 1) * 10,
|
notePosition: (index + 1) * 10,
|
||||||
@ -314,7 +314,7 @@ class Froca {
|
|||||||
*/
|
*/
|
||||||
async getNoteComplement(noteId) {
|
async getNoteComplement(noteId) {
|
||||||
if (!this.noteComplementPromises[noteId]) {
|
if (!this.noteComplementPromises[noteId]) {
|
||||||
this.noteComplementPromises[noteId] = server.get('notes/' + noteId)
|
this.noteComplementPromises[noteId] = server.get(`notes/${noteId}`)
|
||||||
.then(row => new NoteComplement(row))
|
.then(row => new NoteComplement(row))
|
||||||
.catch(e => console.error(`Cannot get note complement for note '${noteId}'`));
|
.catch(e => console.error(`Cannot get note complement for note '${noteId}'`));
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
|
|
||||||
return params.map(p => {
|
return params.map(p => {
|
||||||
if (typeof p === "function") {
|
if (typeof p === "function") {
|
||||||
return "!@#Function: " + p.toString();
|
return `!@#Function: ${p.toString()}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return p;
|
return p;
|
||||||
@ -173,7 +173,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
return ret.executionResult;
|
return ret.executionResult;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("server error: " + ret.error);
|
throw new Error(`server error: ${ret.error}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -564,7 +564,7 @@ function FrontendScriptApi(startNote, currentNote, originEntity = null, $contain
|
|||||||
this.log = message => {
|
this.log = message => {
|
||||||
const {noteId} = this.startNote;
|
const {noteId} = this.startNote;
|
||||||
|
|
||||||
message = utils.now() + ": " + message;
|
message = `${utils.now()}: ${message}`;
|
||||||
|
|
||||||
console.log(`Script ${noteId}: ${message}`);
|
console.log(`Script ${noteId}: ${message}`);
|
||||||
|
|
||||||
|
@ -49,12 +49,12 @@ function setupGlobs() {
|
|||||||
message += 'No details available';
|
message += 'No details available';
|
||||||
} else {
|
} else {
|
||||||
message += [
|
message += [
|
||||||
'Message: ' + msg,
|
`Message: ${msg}`,
|
||||||
'URL: ' + url,
|
`URL: ${url}`,
|
||||||
'Line: ' + lineNo,
|
`Line: ${lineNo}`,
|
||||||
'Column: ' + columnNo,
|
`Column: ${columnNo}`,
|
||||||
'Error object: ' + JSON.stringify(error),
|
`Error object: ${JSON.stringify(error)}`,
|
||||||
'Stack: ' + (error && error.stack)
|
`Stack: ${error && error.stack}`
|
||||||
].join(', ');
|
].join(', ');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ async function checkNoteAccess(notePath, noteContext) {
|
|||||||
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
|
const resolvedNotePath = await treeService.resolveNotePath(notePath, noteContext.hoistedNoteId);
|
||||||
|
|
||||||
if (!resolvedNotePath) {
|
if (!resolvedNotePath) {
|
||||||
console.log("Cannot activate " + notePath);
|
console.log(`Cannot activate ${notePath}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@ export async function uploadFiles(parentNoteId, files, options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
({noteId} = await $.ajax({
|
({noteId} = await $.ajax({
|
||||||
url: baseApiUrl + 'notes/' + parentNoteId + '/import',
|
url: `${baseApiUrl}notes/${parentNoteId}/import`,
|
||||||
headers: await server.getHeaders(),
|
headers: await server.getHeaders(),
|
||||||
data: formData,
|
data: formData,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
timeout: 60 * 60 * 1000,
|
timeout: 60 * 60 * 1000,
|
||||||
error: function(xhr) {
|
error: function(xhr) {
|
||||||
toastService.showError("Import failed: " + xhr.responseText);
|
toastService.showError(`Import failed: ${xhr.responseText}`);
|
||||||
},
|
},
|
||||||
contentType: false, // NEEDED, DON'T REMOVE THIS
|
contentType: false, // NEEDED, DON'T REMOVE THIS
|
||||||
processData: false, // NEEDED, DON'T REMOVE THIS
|
processData: false, // NEEDED, DON'T REMOVE THIS
|
||||||
@ -59,7 +59,7 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.closePersistent(message.taskId);
|
toastService.closePersistent(message.taskId);
|
||||||
toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
} else if (message.type === 'taskProgressCount') {
|
} else if (message.type === 'taskProgressCount') {
|
||||||
toastService.showPersistent(makeToast(message.taskId, "Import in progress: " + message.progressCount));
|
toastService.showPersistent(makeToast(message.taskId, `Import in progress: ${message.progressCount}`));
|
||||||
} else if (message.type === 'taskSucceeded') {
|
} else if (message.type === 'taskSucceeded') {
|
||||||
const toast = makeToast(message.taskId, "Import finished successfully.");
|
const toast = makeToast(message.taskId, "Import finished successfully.");
|
||||||
toast.closeAfter = 5000;
|
toast.closeAfter = 5000;
|
||||||
|
@ -86,7 +86,7 @@ async function requireLibrary(library) {
|
|||||||
const loadedScriptPromises = {};
|
const loadedScriptPromises = {};
|
||||||
|
|
||||||
async function requireScript(url) {
|
async function requireScript(url) {
|
||||||
url = window.glob.assetPath + "/" + url;
|
url = `${window.glob.assetPath}/${url}`;
|
||||||
|
|
||||||
if (!loadedScriptPromises[url]) {
|
if (!loadedScriptPromises[url]) {
|
||||||
loadedScriptPromises[url] = $.ajax({
|
loadedScriptPromises[url] = $.ajax({
|
||||||
@ -106,7 +106,7 @@ async function requireCss(url, prependAssetPath = true) {
|
|||||||
|
|
||||||
if (!cssLinks.some(l => l.endsWith(url))) {
|
if (!cssLinks.some(l => l.endsWith(url))) {
|
||||||
if (prependAssetPath) {
|
if (prependAssetPath) {
|
||||||
url = window.glob.assetPath + "/" + url;
|
url = `${window.glob.assetPath}/${url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
|
$('head').append($('<link rel="stylesheet" type="text/css" />').attr('href', url));
|
||||||
|
@ -20,7 +20,7 @@ async function createNoteLink(notePath, options = {}) {
|
|||||||
if (!notePath.startsWith("root")) {
|
if (!notePath.startsWith("root")) {
|
||||||
// all note paths should start with "root/" (except for "root" itself)
|
// all note paths should start with "root/" (except for "root" itself)
|
||||||
// used e.g. to find internal links
|
// used e.g. to find internal links
|
||||||
notePath = "root/" + notePath;
|
notePath = `root/${notePath}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
let noteTitle = options.title;
|
let noteTitle = options.title;
|
||||||
@ -41,12 +41,12 @@ async function createNoteLink(notePath, options = {}) {
|
|||||||
const note = await froca.getNote(noteId);
|
const note = await froca.getNote(noteId);
|
||||||
|
|
||||||
$container
|
$container
|
||||||
.append($("<span>").addClass("bx " + note.getIcon()))
|
.append($("<span>").addClass(`bx ${note.getIcon()}`))
|
||||||
.append(" ");
|
.append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
const $noteLink = $("<a>", {
|
const $noteLink = $("<a>", {
|
||||||
href: '#' + notePath,
|
href: `#${notePath}`,
|
||||||
text: noteTitle
|
text: noteTitle
|
||||||
}).attr('data-action', 'note')
|
}).attr('data-action', 'note')
|
||||||
.attr('data-note-path', notePath);
|
.attr('data-note-path', notePath);
|
||||||
@ -70,7 +70,7 @@ async function createNoteLink(notePath, options = {}) {
|
|||||||
const parentNotePath = resolvedNotePathSegments.join("/").trim();
|
const parentNotePath = resolvedNotePathSegments.join("/").trim();
|
||||||
|
|
||||||
if (parentNotePath) {
|
if (parentNotePath) {
|
||||||
$container.append($("<small>").text(" (" + await treeService.getNotePathTitle(parentNotePath) + ")"));
|
$container.append($("<small>").text(` (${await treeService.getNotePathTitle(parentNotePath)})`));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,9 +17,9 @@ async function autocompleteSourceForCKEditor(queryText) {
|
|||||||
return {
|
return {
|
||||||
action: row.action,
|
action: row.action,
|
||||||
noteTitle: row.noteTitle,
|
noteTitle: row.noteTitle,
|
||||||
id: '@' + row.notePathTitle,
|
id: `@${row.notePathTitle}`,
|
||||||
name: row.notePathTitle,
|
name: row.notePathTitle,
|
||||||
link: '#' + row.notePath,
|
link: `#${row.notePath}`,
|
||||||
notePath: row.notePath,
|
notePath: row.notePath,
|
||||||
highlightedNotePathTitle: row.highlightedNotePathTitle
|
highlightedNotePathTitle: row.highlightedNotePathTitle
|
||||||
}
|
}
|
||||||
@ -33,9 +33,7 @@ async function autocompleteSourceForCKEditor(queryText) {
|
|||||||
async function autocompleteSource(term, cb, options = {}) {
|
async function autocompleteSource(term, cb, options = {}) {
|
||||||
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
|
const activeNoteId = appContext.tabManager.getActiveContextNoteId();
|
||||||
|
|
||||||
let results = await server.get('autocomplete'
|
let results = await server.get(`autocomplete?query=${encodeURIComponent(term)}&activeNoteId=${activeNoteId}`);
|
||||||
+ '?query=' + encodeURIComponent(term)
|
|
||||||
+ '&activeNoteId=' + activeNoteId);
|
|
||||||
|
|
||||||
if (term.trim().length >= 1 && options.allowCreatingNotes) {
|
if (term.trim().length >= 1 && options.allowCreatingNotes) {
|
||||||
results = [
|
results = [
|
||||||
|
@ -37,7 +37,7 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (type === 'code') {
|
else if (type === 'code') {
|
||||||
const fullNote = await server.get('notes/' + note.noteId);
|
const fullNote = await server.get(`notes/${note.noteId}`);
|
||||||
|
|
||||||
$renderedContent.append($("<pre>").text(trim(fullNote.content, options.trim)));
|
$renderedContent.append($("<pre>").text(trim(fullNote.content, options.trim)));
|
||||||
}
|
}
|
||||||
@ -64,13 +64,13 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
|
|
||||||
if (type === 'pdf') {
|
if (type === 'pdf') {
|
||||||
const $pdfPreview = $('<iframe class="pdf-preview" style="width: 100%; flex-grow: 100;"></iframe>');
|
const $pdfPreview = $('<iframe class="pdf-preview" style="width: 100%; flex-grow: 100;"></iframe>');
|
||||||
$pdfPreview.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open"));
|
$pdfPreview.attr("src", openService.getUrlForDownload(`api/notes/${note.noteId}/open`));
|
||||||
|
|
||||||
$content.append($pdfPreview);
|
$content.append($pdfPreview);
|
||||||
}
|
}
|
||||||
else if (type === 'audio') {
|
else if (type === 'audio') {
|
||||||
const $audioPreview = $('<audio controls></audio>')
|
const $audioPreview = $('<audio controls></audio>')
|
||||||
.attr("src", openService.getUrlForStreaming("api/notes/" + note.noteId + "/open-partial"))
|
.attr("src", openService.getUrlForStreaming(`api/notes/${note.noteId}/open-partial`))
|
||||||
.attr("type", note.mime)
|
.attr("type", note.mime)
|
||||||
.css("width", "100%");
|
.css("width", "100%");
|
||||||
|
|
||||||
@ -78,7 +78,7 @@ async function getRenderedContent(note, options = {}) {
|
|||||||
}
|
}
|
||||||
else if (type === 'video') {
|
else if (type === 'video') {
|
||||||
const $videoPreview = $('<video controls></video>')
|
const $videoPreview = $('<video controls></video>')
|
||||||
.attr("src", openService.getUrlForDownload("api/notes/" + note.noteId + "/open-partial"))
|
.attr("src", openService.getUrlForDownload(`api/notes/${note.noteId}/open-partial`))
|
||||||
.attr("type", note.mime)
|
.attr("type", note.mime)
|
||||||
.css("width", "100%");
|
.css("width", "100%");
|
||||||
|
|
||||||
|
@ -178,7 +178,7 @@ class NoteListRenderer {
|
|||||||
this.viewType = parentNote.type === 'search' ? 'list' : 'grid';
|
this.viewType = parentNote.type === 'search' ? 'list' : 'grid';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$noteList.addClass(this.viewType + '-view');
|
this.$noteList.addClass(`${this.viewType}-view`);
|
||||||
|
|
||||||
this.showNotePath = showNotePath;
|
this.showNotePath = showNotePath;
|
||||||
}
|
}
|
||||||
@ -267,7 +267,7 @@ class NoteListRenderer {
|
|||||||
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
|
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
|
||||||
const notePath = this.parentNote.type === 'search'
|
const notePath = this.parentNote.type === 'search'
|
||||||
? note.noteId // for search note parent we want to display non-search path
|
? note.noteId // for search note parent we want to display non-search path
|
||||||
: this.parentNote.noteId + '/' + note.noteId;
|
: `${this.parentNote.noteId}/${note.noteId}`;
|
||||||
|
|
||||||
const $card = $('<div class="note-book-card">')
|
const $card = $('<div class="note-book-card">')
|
||||||
.attr('data-note-id', note.noteId)
|
.attr('data-note-id', note.noteId)
|
||||||
@ -345,7 +345,7 @@ class NoteListRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content.append($renderedContent);
|
$content.append($renderedContent);
|
||||||
$content.addClass("type-" + type);
|
$content.addClass(`type-${type}`);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(`Caught error while rendering note ${note.noteId} of type ${note.type}: ${e.message}, stack: ${e.stack}`);
|
console.log(`Caught error while rendering note ${note.noteId} of type ${note.type}: ${e.message}, stack: ${e.stack}`);
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ async function mouseEnterHandler() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const html = '<div class="note-tooltip-content">' + content + '</div>';
|
const html = `<div class="note-tooltip-content">${content}</div>`;
|
||||||
|
|
||||||
// we need to check if we're still hovering over the element
|
// we need to check if we're still hovering over the element
|
||||||
// since the operation to get tooltip content was async, it is possible that
|
// since the operation to get tooltip content was async, it is possible that
|
||||||
@ -89,7 +89,7 @@ async function renderTooltip(note) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
let content = '<h5 class="note-tooltip-title">' + (await treeService.getNoteTitleWithPathAsSuffix(someNotePath)).prop('outerHTML') + '</h5>';
|
let content = `<h5 class="note-tooltip-title">${(await treeService.getNoteTitleWithPathAsSuffix(someNotePath)).prop('outerHTML')}</h5>`;
|
||||||
|
|
||||||
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
|
const {$renderedAttributes} = await attributeRenderer.renderNormalAttributes(note);
|
||||||
|
|
||||||
@ -98,9 +98,7 @@ async function renderTooltip(note) {
|
|||||||
trim: true
|
trim: true
|
||||||
});
|
});
|
||||||
|
|
||||||
content = content
|
content = `${content}<div class="note-tooltip-attributes">${$renderedAttributes[0].outerHTML}</div>${$renderedContent[0].outerHTML}`;
|
||||||
+ '<div class="note-tooltip-attributes">' + $renderedAttributes[0].outerHTML + '</div>'
|
|
||||||
+ $renderedContent[0].outerHTML;
|
|
||||||
|
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
@ -2,10 +2,10 @@ import utils from "./utils.js";
|
|||||||
import server from "./server.js";
|
import server from "./server.js";
|
||||||
|
|
||||||
function getFileUrl(noteId) {
|
function getFileUrl(noteId) {
|
||||||
return getUrlForDownload("api/notes/" + noteId + "/download");
|
return getUrlForDownload(`api/notes/${noteId}/download`);
|
||||||
}
|
}
|
||||||
function getOpenFileUrl(noteId) {
|
function getOpenFileUrl(noteId) {
|
||||||
return getUrlForDownload("api/notes/" + noteId + "/open");
|
return getUrlForDownload(`api/notes/${noteId}/open`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function download(url) {
|
function download(url) {
|
||||||
@ -19,14 +19,14 @@ function download(url) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function downloadFileNote(noteId) {
|
function downloadFileNote(noteId) {
|
||||||
const url = getFileUrl(noteId) + '?' + Date.now(); // don't use cache
|
const url = `${getFileUrl(noteId)}?${Date.now()}`; // don't use cache
|
||||||
|
|
||||||
download(url);
|
download(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openNoteExternally(noteId, mime) {
|
async function openNoteExternally(noteId, mime) {
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
const resp = await server.post("notes/" + noteId + "/save-to-tmp-dir");
|
const resp = await server.post(`notes/${noteId}/save-to-tmp-dir`);
|
||||||
|
|
||||||
const electron = utils.dynamicRequire('electron');
|
const electron = utils.dynamicRequire('electron');
|
||||||
const res = await electron.shell.openPath(resp.tmpFilePath);
|
const res = await electron.shell.openPath(resp.tmpFilePath);
|
||||||
@ -59,7 +59,7 @@ function downloadNoteRevision(noteId, noteRevisionId) {
|
|||||||
function getUrlForDownload(url) {
|
function getUrlForDownload(url) {
|
||||||
if (utils.isElectron()) {
|
if (utils.isElectron()) {
|
||||||
// electron needs absolute URL so we extract current host, port, protocol
|
// electron needs absolute URL so we extract current host, port, protocol
|
||||||
return getHost() + '/' + url;
|
return `${getHost()}/${url}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// web server can be deployed on subdomain so we need to use relative path
|
// web server can be deployed on subdomain so we need to use relative path
|
||||||
@ -69,7 +69,7 @@ function getUrlForDownload(url) {
|
|||||||
|
|
||||||
function getHost() {
|
function getHost() {
|
||||||
const url = new URL(window.location.href);
|
const url = new URL(window.location.href);
|
||||||
return url.protocol + "//" + url.hostname + ":" + url.port;
|
return `${url.protocol}//${url.hostname}:${url.port}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -88,7 +88,7 @@ async function protectNote(noteId, protect, includingSubtree) {
|
|||||||
function makeToast(message, protectingLabel, text) {
|
function makeToast(message, protectingLabel, text) {
|
||||||
return {
|
return {
|
||||||
id: message.taskId,
|
id: message.taskId,
|
||||||
title: protectingLabel + " status",
|
title: `${protectingLabel} status`,
|
||||||
message: text,
|
message: text,
|
||||||
icon: message.data.protect ? "check-shield" : "shield"
|
icon: message.data.protect ? "check-shield" : "shield"
|
||||||
};
|
};
|
||||||
@ -105,9 +105,9 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.closePersistent(message.taskId);
|
toastService.closePersistent(message.taskId);
|
||||||
toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
} else if (message.type === 'taskProgressCount') {
|
} else if (message.type === 'taskProgressCount') {
|
||||||
toastService.showPersistent(makeToast(message, protectingLabel,protectingLabel + " in progress: " + message.progressCount));
|
toastService.showPersistent(makeToast(message, protectingLabel,`${protectingLabel} in progress: ${message.progressCount}`));
|
||||||
} else if (message.type === 'taskSucceeded') {
|
} else if (message.type === 'taskSucceeded') {
|
||||||
const toast = makeToast(message, protectingLabel, protectingLabel + " finished successfully.");
|
const toast = makeToast(message, protectingLabel, `${protectingLabel} finished successfully.`);
|
||||||
toast.closeAfter = 3000;
|
toast.closeAfter = 3000;
|
||||||
|
|
||||||
toastService.showPersistent(toast);
|
toastService.showPersistent(toast);
|
||||||
|
@ -10,7 +10,7 @@ async function render(note, $el) {
|
|||||||
$el.empty().toggle(renderNoteIds.length > 0);
|
$el.empty().toggle(renderNoteIds.length > 0);
|
||||||
|
|
||||||
for (const renderNoteId of renderNoteIds) {
|
for (const renderNoteId of renderNoteIds) {
|
||||||
const bundle = await server.get('script/bundle/' + renderNoteId);
|
const bundle = await server.get(`script/bundle/${renderNoteId}`);
|
||||||
|
|
||||||
const $scriptContainer = $('<div>');
|
const $scriptContainer = $('<div>');
|
||||||
$el.append($scriptContainer);
|
$el.append($scriptContainer);
|
||||||
|
@ -20,7 +20,7 @@ async function ScriptContext(startNoteId, allNoteIds, originEntity = null, $cont
|
|||||||
const note = candidates.find(c => c.title === moduleName);
|
const note = candidates.find(c => c.title === moduleName);
|
||||||
|
|
||||||
if (!note) {
|
if (!note) {
|
||||||
throw new Error("Could not find module note " + moduleName);
|
throw new Error(`Could not find module note ${moduleName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return modules[note.noteId].exports;
|
return modules[note.noteId].exports;
|
||||||
|
@ -2,7 +2,7 @@ import server from "./server.js";
|
|||||||
import froca from "./froca.js";
|
import froca from "./froca.js";
|
||||||
|
|
||||||
async function searchForNoteIds(searchString) {
|
async function searchForNoteIds(searchString) {
|
||||||
return await server.get('search/' + encodeURIComponent(searchString));
|
return await server.get(`search/${encodeURIComponent(searchString)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function searchForNotes(searchString) {
|
async function searchForNotes(searchString) {
|
||||||
|
@ -72,14 +72,14 @@ async function call(method, url, data, headers = {}) {
|
|||||||
reqRejects[requestId] = reject;
|
reqRejects[requestId] = reject;
|
||||||
|
|
||||||
if (REQUEST_LOGGING_ENABLED) {
|
if (REQUEST_LOGGING_ENABLED) {
|
||||||
console.log(utils.now(), "Request #" + requestId + " to " + method + " " + url);
|
console.log(utils.now(), `Request #${requestId} to ${method} ${url}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
ipc.send('server-request', {
|
ipc.send('server-request', {
|
||||||
requestId: requestId,
|
requestId: requestId,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
method: method,
|
method: method,
|
||||||
url: "/" + baseApiUrl + url,
|
url: `/${baseApiUrl}${url}`,
|
||||||
data: data
|
data: data
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -117,7 +117,7 @@ async function reportError(method, url, statusCode, response) {
|
|||||||
toastService.showError(response.message);
|
toastService.showError(response.message);
|
||||||
throw new ValidationError(response);
|
throw new ValidationError(response);
|
||||||
} else {
|
} else {
|
||||||
const message = "Error when calling " + method + " " + url + ": " + statusCode + " - " + response;
|
const message = `Error when calling ${method} ${url}: ${statusCode} - ${response}`;
|
||||||
toastService.showError(message);
|
toastService.showError(message);
|
||||||
toastService.throwError(message);
|
toastService.throwError(message);
|
||||||
}
|
}
|
||||||
@ -169,7 +169,7 @@ if (utils.isElectron()) {
|
|||||||
|
|
||||||
ipc.on('server-response', async (event, arg) => {
|
ipc.on('server-response', async (event, arg) => {
|
||||||
if (REQUEST_LOGGING_ENABLED) {
|
if (REQUEST_LOGGING_ENABLED) {
|
||||||
console.log(utils.now(), "Response #" + arg.requestId + ": " + arg.statusCode);
|
console.log(utils.now(), `Response #${arg.requestId}: ${arg.statusCode}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg.statusCode >= 200 && arg.statusCode < 300) {
|
if (arg.statusCode >= 200 && arg.statusCode < 300) {
|
||||||
|
@ -15,7 +15,7 @@ function bindElShortcut($el, keyboardShortcut, handler, namespace = null) {
|
|||||||
let eventName = 'keydown';
|
let eventName = 'keydown';
|
||||||
|
|
||||||
if (namespace) {
|
if (namespace) {
|
||||||
eventName += "." + namespace;
|
eventName += `.${namespace}`;
|
||||||
|
|
||||||
// if there's a namespace then we replace the existing event handler with the new one
|
// if there's a namespace then we replace the existing event handler with the new one
|
||||||
$el.off(eventName);
|
$el.off(eventName);
|
||||||
|
@ -9,17 +9,17 @@ async function syncNow(ignoreNotConfigured = false) {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (result.message.length > 200) {
|
if (result.message.length > 200) {
|
||||||
result.message = result.message.substr(0, 200) + "...";
|
result.message = `${result.message.substr(0, 200)}...`;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ignoreNotConfigured || result.errorCode !== 'NOT_CONFIGURED') {
|
if (!ignoreNotConfigured || result.errorCode !== 'NOT_CONFIGURED') {
|
||||||
toastService.showError("Sync failed: " + result.message);
|
toastService.showError(`Sync failed: ${result.message}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function forceNoteSync(noteId) {
|
async function forceNoteSync(noteId) {
|
||||||
await server.post('sync/force-note-sync/' + noteId);
|
await server.post(`sync/force-note-sync/${noteId}`);
|
||||||
|
|
||||||
toastService.showMessage("Note added to sync queue.");
|
toastService.showMessage("Note added to sync queue.");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ function toast(options) {
|
|||||||
$toast.find('.toast-body').text(options.message);
|
$toast.find('.toast-body').text(options.message);
|
||||||
|
|
||||||
if (options.id) {
|
if (options.id) {
|
||||||
$toast.attr("id", "toast-" + options.id);
|
$toast.attr("id", `toast-${options.id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#toast-container").append($toast);
|
$("#toast-container").append($toast);
|
||||||
@ -34,7 +34,7 @@ function toast(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function showPersistent(options) {
|
function showPersistent(options) {
|
||||||
let $toast = $("#toast-" + options.id);
|
let $toast = $(`#toast-${options.id}`);
|
||||||
|
|
||||||
if ($toast.length > 0) {
|
if ($toast.length > 0) {
|
||||||
$toast.find('.toast-body').html(options.message);
|
$toast.find('.toast-body').html(options.message);
|
||||||
@ -51,7 +51,7 @@ function showPersistent(options) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function closePersistent(id) {
|
function closePersistent(id) {
|
||||||
$("#toast-" + id).remove();
|
$(`#toast-${id}`).remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function showMessage(message, delay = 2000) {
|
function showMessage(message, delay = 2000) {
|
||||||
|
@ -292,7 +292,7 @@ async function getNoteTitleWithPathAsSuffix(notePath) {
|
|||||||
|
|
||||||
if (path.length > 0) {
|
if (path.length > 0) {
|
||||||
$titleWithPath
|
$titleWithPath
|
||||||
.append($('<span class="note-path">').text(' (' + path.join(' / ') + ')'));
|
.append($('<span class="note-path">').text(` (${path.join(' / ')})`));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $titleWithPath;
|
return $titleWithPath;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
function reloadFrontendApp(reason) {
|
function reloadFrontendApp(reason) {
|
||||||
if (reason) {
|
if (reason) {
|
||||||
logInfo("Frontend app reload: " + reason);
|
logInfo(`Frontend app reload: ${reason}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
window.location.reload(true);
|
window.location.reload(true);
|
||||||
@ -11,20 +11,20 @@ function parseDate(str) {
|
|||||||
return new Date(Date.parse(str));
|
return new Date(Date.parse(str));
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
throw new Error("Can't parse date from " + str + ": " + e.stack);
|
throw new Error(`Can't parse date from ${str}: ${e.stack}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function padNum(num) {
|
function padNum(num) {
|
||||||
return (num <= 9 ? "0" : "") + num;
|
return `${num <= 9 ? "0" : ""}${num}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTime(date) {
|
function formatTime(date) {
|
||||||
return padNum(date.getHours()) + ":" + padNum(date.getMinutes());
|
return `${padNum(date.getHours())}:${padNum(date.getMinutes())}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatTimeWithSeconds(date) {
|
function formatTimeWithSeconds(date) {
|
||||||
return padNum(date.getHours()) + ":" + padNum(date.getMinutes()) + ":" + padNum(date.getSeconds());
|
return `${padNum(date.getHours())}:${padNum(date.getMinutes())}:${padNum(date.getSeconds())}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is producing local time!
|
// this is producing local time!
|
||||||
@ -37,11 +37,11 @@ function formatDate(date) {
|
|||||||
|
|
||||||
// this is producing local time!
|
// this is producing local time!
|
||||||
function formatDateISO(date) {
|
function formatDateISO(date) {
|
||||||
return date.getFullYear() + "-" + padNum(date.getMonth() + 1) + "-" + padNum(date.getDate());
|
return `${date.getFullYear()}-${padNum(date.getMonth() + 1)}-${padNum(date.getDate())}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatDateTime(date) {
|
function formatDateTime(date) {
|
||||||
return formatDate(date) + " " + formatTime(date);
|
return `${formatDate(date)} ${formatTime(date)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function localNowDateTime() {
|
function localNowDateTime() {
|
||||||
@ -101,14 +101,14 @@ async function stopWatch(what, func) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function formatValueWithWhitespace(val) {
|
function formatValueWithWhitespace(val) {
|
||||||
return /[^\w_-]/.test(val) ? '"' + val + '"' : val;
|
return /[^\w_-]/.test(val) ? `"${val}"` : val;
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatLabel(label) {
|
function formatLabel(label) {
|
||||||
let str = "#" + formatValueWithWhitespace(label.name);
|
let str = `#${formatValueWithWhitespace(label.name)}`;
|
||||||
|
|
||||||
if (label.value !== "") {
|
if (label.value !== "") {
|
||||||
str += "=" + formatValueWithWhitespace(label.value);
|
str += `=${formatValueWithWhitespace(label.value)}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
@ -154,22 +154,22 @@ function isDesktop() {
|
|||||||
|
|
||||||
function setCookie(name, value) {
|
function setCookie(name, value) {
|
||||||
const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000);
|
const date = new Date(Date.now() + 10 * 365 * 24 * 60 * 60 * 1000);
|
||||||
const expires = "; expires=" + date.toUTCString();
|
const expires = `; expires=${date.toUTCString()}`;
|
||||||
|
|
||||||
document.cookie = name + "=" + (value || "") + expires + ";";
|
document.cookie = `${name}=${value || ""}${expires};`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function setSessionCookie(name, value) {
|
function setSessionCookie(name, value) {
|
||||||
document.cookie = name + "=" + (value || "") + "; SameSite=Strict";
|
document.cookie = `${name}=${value || ""}; SameSite=Strict`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCookie(name) {
|
function getCookie(name) {
|
||||||
const valueMatch = document.cookie.match('(^|;) ?' + name + '=([^;]*)(;|$)');
|
const valueMatch = document.cookie.match(`(^|;) ?${name}=([^;]*)(;|$)`);
|
||||||
return valueMatch ? valueMatch[2] : null;
|
return valueMatch ? valueMatch[2] : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNoteTypeClass(type) {
|
function getNoteTypeClass(type) {
|
||||||
return "type-" + type;
|
return `type-${type}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMimeTypeClass(mime) {
|
function getMimeTypeClass(mime) {
|
||||||
@ -184,7 +184,7 @@ function getMimeTypeClass(mime) {
|
|||||||
mime = mime.substr(0, semicolonIdx);
|
mime = mime.substr(0, semicolonIdx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'mime-' + mime.toLowerCase().replace(/[\W_]+/g,"-");
|
return `mime-${mime.toLowerCase().replace(/[\W_]+/g, "-")}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function closeActiveDialog() {
|
function closeActiveDialog() {
|
||||||
|
@ -195,8 +195,7 @@ async function consumeFrontendUpdateData() {
|
|||||||
|
|
||||||
function connectWebSocket() {
|
function connectWebSocket() {
|
||||||
const loc = window.location;
|
const loc = window.location;
|
||||||
const webSocketUri = (loc.protocol === "https:" ? "wss:" : "ws:")
|
const webSocketUri = `${loc.protocol === "https:" ? "wss:" : "ws:"}//${loc.host}${loc.pathname}`;
|
||||||
+ "//" + loc.host + loc.pathname;
|
|
||||||
|
|
||||||
// use wss for secure messaging
|
// use wss for secure messaging
|
||||||
const ws = new WebSocket(webSocketUri);
|
const ws = new WebSocket(webSocketUri);
|
||||||
|
@ -8,7 +8,7 @@ function SetupModel() {
|
|||||||
setInterval(checkOutstandingSyncs, 1000);
|
setInterval(checkOutstandingSyncs, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
const serverAddress = location.protocol + '//' + location.host;
|
const serverAddress = `${location.protocol}//${location.host}`;
|
||||||
|
|
||||||
$("#current-host").html(serverAddress);
|
$("#current-host").html(serverAddress);
|
||||||
|
|
||||||
@ -74,7 +74,7 @@ function SetupModel() {
|
|||||||
hideAlert();
|
hideAlert();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
showAlert('Sync setup failed: ' + resp.error);
|
showAlert(`Sync setup failed: ${resp.error}`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -628,9 +628,9 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.attrType === 'label-definition') {
|
if (this.attrType === 'label-definition') {
|
||||||
attrName = 'label:' + attrName;
|
attrName = `label:${attrName}`;
|
||||||
} else if (this.attrType === 'relation-definition') {
|
} else if (this.attrType === 'relation-definition') {
|
||||||
attrName = 'relation:' + attrName;
|
attrName = `relation:${attrName}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.attribute.name = attrName;
|
this.attribute.name = attrName;
|
||||||
@ -662,12 +662,12 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
|
|||||||
props.push(this.$inputLabelType.val());
|
props.push(this.$inputLabelType.val());
|
||||||
|
|
||||||
if (this.$inputLabelType.val() === 'number' && this.$inputNumberPrecision.val() !== '') {
|
if (this.$inputLabelType.val() === 'number' && this.$inputNumberPrecision.val() !== '') {
|
||||||
props.push('precision=' + this.$inputNumberPrecision.val());
|
props.push(`precision=${this.$inputNumberPrecision.val()}`);
|
||||||
}
|
}
|
||||||
} else if (this.attrType === 'relation-definition' && this.$inputInverseRelation.val().trim().length > 0) {
|
} else if (this.attrType === 'relation-definition' && this.$inputInverseRelation.val().trim().length > 0) {
|
||||||
const inverseRelationName = this.$inputInverseRelation.val();
|
const inverseRelationName = this.$inputInverseRelation.val();
|
||||||
|
|
||||||
props.push("inverse=" + utils.filterAttributeName(inverseRelationName));
|
props.push(`inverse=${utils.filterAttributeName(inverseRelationName)}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$rowNumberPrecision.toggle(
|
this.$rowNumberPrecision.toggle(
|
||||||
@ -683,7 +683,7 @@ export default class AttributeDetailWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
createNoteLink(noteId) {
|
createNoteLink(noteId) {
|
||||||
return $("<a>", {
|
return $("<a>", {
|
||||||
href: '#' + noteId,
|
href: `#${noteId}`,
|
||||||
class: 'reference-link',
|
class: 'reference-link',
|
||||||
'data-note-path': noteId
|
'data-note-path': noteId
|
||||||
});
|
});
|
||||||
|
@ -99,7 +99,7 @@ const mentionSetup = {
|
|||||||
|
|
||||||
return names.map(name => {
|
return names.map(name => {
|
||||||
return {
|
return {
|
||||||
id: '#' + name,
|
id: `#${name}`,
|
||||||
name: name
|
name: name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -114,7 +114,7 @@ const mentionSetup = {
|
|||||||
|
|
||||||
return names.map(name => {
|
return names.map(name => {
|
||||||
return {
|
return {
|
||||||
id: '~' + name,
|
id: `~${name}`,
|
||||||
name: name
|
name: name
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -20,7 +20,7 @@ export default class BookmarkSwitchWidget extends SwitchWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async toggle(state) {
|
async toggle(state) {
|
||||||
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/` + !!state);
|
const resp = await server.put(`notes/${this.noteId}/toggle-in-parent/lbBookmarks/${!!state}`);
|
||||||
|
|
||||||
if (!resp.success) {
|
if (!resp.success) {
|
||||||
toastService.showError(resp.message);
|
toastService.showError(resp.message);
|
||||||
|
@ -78,7 +78,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
|||||||
|
|
||||||
init(activeDate) {
|
init(activeDate) {
|
||||||
// attaching time fixes local timezone handling
|
// attaching time fixes local timezone handling
|
||||||
this.activeDate = activeDate ? new Date(activeDate + "T12:00:00") : null;
|
this.activeDate = activeDate ? new Date(`${activeDate}T12:00:00`) : null;
|
||||||
this.todaysDate = new Date();
|
this.todaysDate = new Date();
|
||||||
this.date = new Date((this.activeDate || this.todaysDate).getTime());
|
this.date = new Date((this.activeDate || this.todaysDate).getTime());
|
||||||
this.date.setDate(1);
|
this.date.setDate(1);
|
||||||
@ -97,7 +97,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
|||||||
if (day === 0) {
|
if (day === 0) {
|
||||||
$newDay.css("marginLeft", (6 * 14.28) + '%');
|
$newDay.css("marginLeft", (6 * 14.28) + '%');
|
||||||
} else {
|
} else {
|
||||||
$newDay.css("marginLeft", ((day - 1) * 14.28) + '%');
|
$newDay.css("marginLeft", `${(day - 1) * 14.28}%`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
|||||||
|
|
||||||
async createMonth() {
|
async createMonth() {
|
||||||
const month = utils.formatDateISO(this.date).substr(0, 7);
|
const month = utils.formatDateISO(this.date).substr(0, 7);
|
||||||
const dateNotesForMonth = await server.get('special-notes/notes-for-month/' + month);
|
const dateNotesForMonth = await server.get(`special-notes/notes-for-month/${month}`);
|
||||||
|
|
||||||
this.$month.empty();
|
this.$month.empty();
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ export default class CalendarWidget extends RightDropdownButtonWidget {
|
|||||||
this.date.setDate(1);
|
this.date.setDate(1);
|
||||||
this.date.setMonth(this.date.getMonth() - 1);
|
this.date.setMonth(this.date.getMonth() - 1);
|
||||||
|
|
||||||
this.$label.html(this.monthsAsString(this.date.getMonth()) + ' ' + this.date.getFullYear());
|
this.$label.html(`${this.monthsAsString(this.date.getMonth())} ${this.date.getFullYear()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
monthsAsString(monthIndex) {
|
monthsAsString(monthIndex) {
|
||||||
|
@ -281,7 +281,7 @@ export default class GlobalMenuWidget extends BasicWidget {
|
|||||||
const zoomFactor = utils.dynamicRequire('electron').webFrame.getZoomFactor();
|
const zoomFactor = utils.dynamicRequire('electron').webFrame.getZoomFactor();
|
||||||
const zoomPercent = Math.round(zoomFactor * 100);
|
const zoomPercent = Math.round(zoomFactor * 100);
|
||||||
|
|
||||||
this.$zoomState.text(zoomPercent + "%");
|
this.$zoomState.text(`${zoomPercent}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateVersionStatus() {
|
async updateVersionStatus() {
|
||||||
|
@ -20,7 +20,7 @@ export default class CollapsibleWidget extends NoteContextAwareWidget {
|
|||||||
doRender() {
|
doRender() {
|
||||||
this.$widget = $(WIDGET_TPL);
|
this.$widget = $(WIDGET_TPL);
|
||||||
this.contentSized();
|
this.contentSized();
|
||||||
this.$widget.find('[data-target]').attr('data-target', "#" + this.componentId);
|
this.$widget.find('[data-target]').attr('data-target', `#${this.componentId}`);
|
||||||
|
|
||||||
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
this.$bodyWrapper = this.$widget.find('.body-wrapper');
|
||||||
this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id
|
this.$bodyWrapper.attr('id', this.componentId); // for toggle to work we need id
|
||||||
|
@ -70,7 +70,7 @@ export default class AboutDialog extends BasicWidget {
|
|||||||
this.$syncVersion.text(appInfo.syncVersion);
|
this.$syncVersion.text(appInfo.syncVersion);
|
||||||
this.$buildDate.text(appInfo.buildDate);
|
this.$buildDate.text(appInfo.buildDate);
|
||||||
this.$buildRevision.text(appInfo.buildRevision);
|
this.$buildRevision.text(appInfo.buildRevision);
|
||||||
this.$buildRevision.attr('href', 'https://github.com/zadam/trilium/commit/' + appInfo.buildRevision);
|
this.$buildRevision.attr('href', `https://github.com/zadam/trilium/commit/${appInfo.buildRevision}`);
|
||||||
this.$dataDirectory.text(appInfo.dataDirectory);
|
this.$dataDirectory.text(appInfo.dataDirectory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +82,7 @@ export default class BranchPrefixDialog extends BasicWidget {
|
|||||||
|
|
||||||
const noteTitle = await treeService.getNoteTitle(noteId);
|
const noteTitle = await treeService.getNoteTitle(noteId);
|
||||||
|
|
||||||
this.$noteTitle.text(" - " + noteTitle);
|
this.$noteTitle.text(` - ${noteTitle}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async editBranchPrefixEvent() {
|
async editBranchPrefixEvent() {
|
||||||
|
@ -130,7 +130,7 @@ export default class BulkActionsDialog extends BasicWidget {
|
|||||||
for (const actionGroup of bulkActionService.ACTION_GROUPS) {
|
for (const actionGroup of bulkActionService.ACTION_GROUPS) {
|
||||||
const $actionGroupList = $("<td>");
|
const $actionGroupList = $("<td>");
|
||||||
const $actionGroup = $("<tr>")
|
const $actionGroup = $("<tr>")
|
||||||
.append($("<td>").text(actionGroup.title + ": "))
|
.append($("<td>").text(`${actionGroup.title}: `))
|
||||||
.append($actionGroupList);
|
.append($actionGroupList);
|
||||||
|
|
||||||
for (const action of actionGroup.actions) {
|
for (const action of actionGroup.actions) {
|
||||||
|
@ -96,7 +96,7 @@ export default class ConfirmDialog extends BasicWidget {
|
|||||||
.append(
|
.append(
|
||||||
$("<input>")
|
$("<input>")
|
||||||
.attr("type", "checkbox")
|
.attr("type", "checkbox")
|
||||||
.addClass("form-check-input " + DELETE_NOTE_BUTTON_CLASS)
|
.addClass(`form-check-input ${DELETE_NOTE_BUTTON_CLASS}`)
|
||||||
)
|
)
|
||||||
.append("Also delete the note")
|
.append("Also delete the note")
|
||||||
));
|
));
|
||||||
@ -111,7 +111,7 @@ export default class ConfirmDialog extends BasicWidget {
|
|||||||
doResolve(ret) {
|
doResolve(ret) {
|
||||||
this.resolve({
|
this.resolve({
|
||||||
confirmed: ret,
|
confirmed: ret,
|
||||||
isDeleteNoteChecked: this.$widget.find("." + DELETE_NOTE_BUTTON_CLASS + ":checked").length > 0
|
isDeleteNoteChecked: this.$widget.find(`.${DELETE_NOTE_BUTTON_CLASS}:checked`).length > 0
|
||||||
});
|
});
|
||||||
|
|
||||||
this.resolve = null;
|
this.resolve = null;
|
||||||
|
@ -203,7 +203,7 @@ export default class ExportDialog extends BasicWidget {
|
|||||||
this.$singleType.prop("checked", true).trigger('change');
|
this.$singleType.prop("checked", true).trigger('change');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Unrecognized type " + defaultType);
|
throw new Error(`Unrecognized type ${defaultType}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$widget.find(".opml-v2").prop("checked", true); // setting default
|
this.$widget.find(".opml-v2").prop("checked", true); // setting default
|
||||||
@ -242,7 +242,7 @@ ws.subscribeToMessages(async message => {
|
|||||||
toastService.showError(message.message);
|
toastService.showError(message.message);
|
||||||
}
|
}
|
||||||
else if (message.type === 'taskProgressCount') {
|
else if (message.type === 'taskProgressCount') {
|
||||||
toastService.showPersistent(makeToast(message.taskId, "Export in progress: " + message.progressCount));
|
toastService.showPersistent(makeToast(message.taskId, `Export in progress: ${message.progressCount}`));
|
||||||
}
|
}
|
||||||
else if (message.type === 'taskSucceeded') {
|
else if (message.type === 'taskSucceeded') {
|
||||||
const toast = makeToast(message.taskId, "Export finished successfully.");
|
const toast = makeToast(message.taskId, "Export finished successfully.");
|
||||||
|
@ -147,9 +147,9 @@ export default class NoteRevisionsDialog extends BasicWidget {
|
|||||||
for (const item of this.revisionItems) {
|
for (const item of this.revisionItems) {
|
||||||
this.$list.append(
|
this.$list.append(
|
||||||
$('<a class="dropdown-item" tabindex="0">')
|
$('<a class="dropdown-item" tabindex="0">')
|
||||||
.text(item.dateLastEdited.substr(0, 16) + ` (${item.contentLength} bytes)`)
|
.text(`${item.dateLastEdited.substr(0, 16)} (${item.contentLength} bytes)`)
|
||||||
.attr('data-note-revision-id', item.noteRevisionId)
|
.attr('data-note-revision-id', item.noteRevisionId)
|
||||||
.attr('title', 'This revision was last edited on ' + item.dateLastEdited)
|
.attr('title', `This revision was last edited on ${item.dateLastEdited}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +241,7 @@ export default class NoteRevisionsDialog extends BasicWidget {
|
|||||||
this.$content.html($("<img>")
|
this.$content.html($("<img>")
|
||||||
// reason why we put this inline as base64 is that we do not want to let user to copy this
|
// reason why we put this inline as base64 is that we do not want to let user to copy this
|
||||||
// as a URL to be used in a note. Instead if they copy and paste it into a note, it will be a uploaded as a new note
|
// as a URL to be used in a note. Instead if they copy and paste it into a note, it will be a uploaded as a new note
|
||||||
.attr("src", `data:${note.mime};base64,` + fullNoteRevision.content)
|
.attr("src", `data:${note.mime};base64,${fullNoteRevision.content}`)
|
||||||
.css("max-width", "100%")
|
.css("max-width", "100%")
|
||||||
.css("max-height", "100%"));
|
.css("max-height", "100%"));
|
||||||
}
|
}
|
||||||
@ -253,7 +253,7 @@ export default class NoteRevisionsDialog extends BasicWidget {
|
|||||||
))
|
))
|
||||||
.append($("<tr>").append(
|
.append($("<tr>").append(
|
||||||
$("<th>").text("File size:"),
|
$("<th>").text("File size:"),
|
||||||
$("<td>").text(revisionItem.contentLength + " bytes")
|
$("<td>").text(`${revisionItem.contentLength} bytes`)
|
||||||
));
|
));
|
||||||
|
|
||||||
if (fullNoteRevision.content) {
|
if (fullNoteRevision.content) {
|
||||||
|
@ -54,13 +54,15 @@ export default class NoteSourceDialog extends BasicWidget {
|
|||||||
let textNode;
|
let textNode;
|
||||||
|
|
||||||
for (let i = 0; i < node.children.length; i++) {
|
for (let i = 0; i < node.children.length; i++) {
|
||||||
textNode = document.createTextNode('\n' + indentBefore);
|
textNode = document.createTextNode(`
|
||||||
|
${indentBefore}`);
|
||||||
node.insertBefore(textNode, node.children[i]);
|
node.insertBefore(textNode, node.children[i]);
|
||||||
|
|
||||||
this.formatNode(node.children[i], level);
|
this.formatNode(node.children[i], level);
|
||||||
|
|
||||||
if (node.lastElementChild === node.children[i]) {
|
if (node.lastElementChild === node.children[i]) {
|
||||||
textNode = document.createTextNode('\n' + indentAfter);
|
textNode = document.createTextNode(`
|
||||||
|
${indentAfter}`);
|
||||||
node.appendChild(textNode);
|
node.appendChild(textNode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ export default class NoteTypeChooserDialog extends BasicWidget {
|
|||||||
.attr("data-note-type", noteType.type)
|
.attr("data-note-type", noteType.type)
|
||||||
.attr("data-template-note-id", noteType.templateNoteId)
|
.attr("data-template-note-id", noteType.templateNoteId)
|
||||||
.append($("<span>").addClass(noteType.uiIcon))
|
.append($("<span>").addClass(noteType.uiIcon))
|
||||||
.append(" " + noteType.title)
|
.append(` ${noteType.title}`)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ export default class RecentChangesDialog extends BasicWidget {
|
|||||||
this.ancestorNoteId = hoistedNoteService.getHoistedNoteId();
|
this.ancestorNoteId = hoistedNoteService.getHoistedNoteId();
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentChangesRows = await server.get('recent-changes/' + this.ancestorNoteId);
|
const recentChangesRows = await server.get(`recent-changes/${this.ancestorNoteId}`);
|
||||||
|
|
||||||
// preload all notes into cache
|
// preload all notes into cache
|
||||||
await froca.getNotes(recentChangesRows.map(r => r.noteId), true);
|
await froca.getNotes(recentChangesRows.map(r => r.noteId), true);
|
||||||
|
@ -37,7 +37,7 @@ export default class FindInHtml {
|
|||||||
separateWordSearch: false,
|
separateWordSearch: false,
|
||||||
caseSensitive: matchCase,
|
caseSensitive: matchCase,
|
||||||
done: async () => {
|
done: async () => {
|
||||||
this.$results = $content.find("." + FIND_RESULT_CSS_CLASSNAME);
|
this.$results = $content.find(`.${FIND_RESULT_CSS_CLASSNAME}`);
|
||||||
this.currentIndex = 0;
|
this.currentIndex = 0;
|
||||||
await this.jumpTo();
|
await this.jumpTo();
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ export default class CodeButtonsWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
await appContext.tabManager.getActiveContext().setNote(notePath);
|
await appContext.tabManager.getActiveContext().setNote(notePath);
|
||||||
|
|
||||||
toastService.showMessage("SQL Console note has been saved into " + await treeService.getNotePathTitle(notePath));
|
toastService.showMessage(`SQL Console note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
keyboardActionService.updateDisplayedShortcuts(this.$widget);
|
keyboardActionService.updateDisplayedShortcuts(this.$widget);
|
||||||
|
@ -133,7 +133,7 @@ export default class BacklinksWidget extends NoteContextAwareWidget {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
if (backlink.relationName) {
|
if (backlink.relationName) {
|
||||||
$item.append($("<p>").text("relation: " + backlink.relationName));
|
$item.append($("<p>").text(`relation: ${backlink.relationName}`));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$item.append(...backlink.excerpts);
|
$item.append(...backlink.excerpts);
|
||||||
|
@ -78,9 +78,9 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
await wheelZoomLoaded;
|
await wheelZoomLoaded;
|
||||||
|
|
||||||
this.$display.attr("id", 'mermaid-render-' + idCounter);
|
this.$display.attr("id", `mermaid-render-${idCounter}`);
|
||||||
|
|
||||||
WZoom.create('#mermaid-render-' + idCounter, {
|
WZoom.create(`#mermaid-render-${idCounter}`, {
|
||||||
type: 'html',
|
type: 'html',
|
||||||
maxScale: 10,
|
maxScale: 10,
|
||||||
speed: 20,
|
speed: 20,
|
||||||
@ -101,7 +101,7 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|||||||
const noteComplement = await froca.getNoteComplement(this.noteId);
|
const noteComplement = await froca.getNoteComplement(this.noteId);
|
||||||
const content = noteComplement.content || "";
|
const content = noteComplement.content || "";
|
||||||
|
|
||||||
mermaid.mermaidAPI.render('mermaid-graph-' + idCounter, content, res);
|
mermaid.mermaidAPI.render(`mermaid-graph-${idCounter}`, content, res);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,12 +118,12 @@ export default class MermaidWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
const renderedSvg = await this.renderSvg();
|
const renderedSvg = await this.renderSvg();
|
||||||
|
|
||||||
this.download(this.note.title + ".svg", renderedSvg);
|
this.download(`${this.note.title}.svg`, renderedSvg);
|
||||||
}
|
}
|
||||||
|
|
||||||
download(filename, text) {
|
download(filename, text) {
|
||||||
const element = document.createElement('a');
|
const element = document.createElement('a');
|
||||||
element.setAttribute('href', 'data:image/svg+xml;charset=utf-8,' + encodeURIComponent(text));
|
element.setAttribute('href', `data:image/svg+xml;charset=utf-8,${encodeURIComponent(text)}`);
|
||||||
element.setAttribute('download', filename);
|
element.setAttribute('download', filename);
|
||||||
|
|
||||||
element.style.display = 'none';
|
element.style.display = 'none';
|
||||||
|
@ -40,7 +40,7 @@ class MobileDetailMenuWidget extends BasicWidget {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new Error("Unrecognized command " + command);
|
throw new Error(`Unrecognized command ${command}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -170,7 +170,7 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
getTypeWidget() {
|
getTypeWidget() {
|
||||||
if (!this.typeWidgets[this.type]) {
|
if (!this.typeWidgets[this.type]) {
|
||||||
throw new Error("Could not find typeWidget for type: " + this.type);
|
throw new Error(`Could not find typeWidget for type: ${this.type}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.typeWidgets[this.type];
|
return this.typeWidgets[this.type];
|
||||||
@ -268,13 +268,13 @@ export default class NoteDetailWidget extends NoteContextAwareWidget {
|
|||||||
`,
|
`,
|
||||||
importCSS: false,
|
importCSS: false,
|
||||||
loadCSS: [
|
loadCSS: [
|
||||||
assetPath + "/libraries/codemirror/codemirror.css",
|
`${assetPath}/libraries/codemirror/codemirror.css`,
|
||||||
assetPath + "/libraries/ckeditor/ckeditor-content.css",
|
`${assetPath}/libraries/ckeditor/ckeditor-content.css`,
|
||||||
assetPath + "/libraries/bootstrap/css/bootstrap.min.css",
|
`${assetPath}/libraries/bootstrap/css/bootstrap.min.css`,
|
||||||
assetPath + "/libraries/katex/katex.min.css",
|
`${assetPath}/libraries/katex/katex.min.css`,
|
||||||
assetPath + "/stylesheets/print.css",
|
`${assetPath}/stylesheets/print.css`,
|
||||||
assetPath + "/stylesheets/relation_map.css",
|
`${assetPath}/stylesheets/relation_map.css`,
|
||||||
assetPath + "/stylesheets/ckeditor-theme.css"
|
`${assetPath}/stylesheets/ckeditor-theme.css`
|
||||||
],
|
],
|
||||||
debug: true
|
debug: true
|
||||||
});
|
});
|
||||||
|
@ -119,7 +119,7 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
this.$icon.removeClass().addClass(note.getIcon() + " note-icon");
|
this.$icon.removeClass().addClass(`${note.getIcon()} note-icon`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async entitiesReloadedEvent({loadResults}) {
|
async entitiesReloadedEvent({loadResults}) {
|
||||||
@ -193,13 +193,13 @@ export default class NoteIconWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
getIconClass(icon) {
|
getIconClass(icon) {
|
||||||
if (icon.type_of_icon === 'LOGO') {
|
if (icon.type_of_icon === 'LOGO') {
|
||||||
return "bx bxl-" + icon.name;
|
return `bx bxl-${icon.name}`;
|
||||||
}
|
}
|
||||||
else if (icon.type_of_icon === 'SOLID') {
|
else if (icon.type_of_icon === 'SOLID') {
|
||||||
return "bx bxs-" + icon.name;
|
return `bx bxs-${icon.name}`;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return "bx bx-" + icon.name;
|
return `bx bx-${icon.name}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -163,7 +163,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
generateColorFromString(str) {
|
generateColorFromString(str) {
|
||||||
if (this.themeStyle === "dark") {
|
if (this.themeStyle === "dark") {
|
||||||
str = "0" + str; // magic lightening modifier
|
str = `0${str}`; // magic lightening modifier
|
||||||
}
|
}
|
||||||
|
|
||||||
let hash = 0;
|
let hash = 0;
|
||||||
@ -175,7 +175,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||||||
for (let i = 0; i < 3; i++) {
|
for (let i = 0; i < 3; i++) {
|
||||||
const value = (hash >> (i * 8)) & 0xFF;
|
const value = (hash >> (i * 8)) & 0xFF;
|
||||||
|
|
||||||
color += ('00' + value.toString(16)).substr(-2);
|
color += (`00${value.toString(16)}`).substr(-2);
|
||||||
}
|
}
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
@ -209,14 +209,14 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx.fillStyle = this.css.textColor;
|
ctx.fillStyle = this.css.textColor;
|
||||||
ctx.font = size + 'px ' + this.css.fontFamily;
|
ctx.font = `${size}px ${this.css.fontFamily}`;
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
|
|
||||||
let title = node.name;
|
let title = node.name;
|
||||||
|
|
||||||
if (title.length > 15) {
|
if (title.length > 15) {
|
||||||
title = title.substr(0, 15) + "...";
|
title = `${title.substr(0, 15)}...`;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.fillText(title, x, y + Math.round(size * 1.5));
|
ctx.fillText(title, x, y + Math.round(size * 1.5));
|
||||||
@ -227,7 +227,7 @@ export default class NoteMapWidget extends NoteContextAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx.font = '3px ' + this.css.fontFamily;
|
ctx.font = `3px ${this.css.fontFamily}`;
|
||||||
ctx.textAlign = 'center';
|
ctx.textAlign = 'center';
|
||||||
ctx.textBaseline = 'middle';
|
ctx.textBaseline = 'middle';
|
||||||
ctx.fillStyle = this.css.mutedTextColor;
|
ctx.fillStyle = this.css.mutedTextColor;
|
||||||
|
@ -273,19 +273,19 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get hideArchivedNotes() {
|
get hideArchivedNotes() {
|
||||||
return options.is("hideArchivedNotes_" + this.treeName);
|
return options.is(`hideArchivedNotes_${this.treeName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setHideArchivedNotes(val) {
|
async setHideArchivedNotes(val) {
|
||||||
await options.save("hideArchivedNotes_" + this.treeName, val.toString());
|
await options.save(`hideArchivedNotes_${this.treeName}`, val.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
get hideIncludedImages() {
|
get hideIncludedImages() {
|
||||||
return options.is("hideIncludedImages_" + this.treeName);
|
return options.is(`hideIncludedImages_${this.treeName}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async setHideIncludedImages(val) {
|
async setHideIncludedImages(val) {
|
||||||
await options.save("hideIncludedImages_" + this.treeName, val.toString());
|
await options.save(`hideIncludedImages_${this.treeName}`, val.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
get autoCollapseNoteTree() {
|
get autoCollapseNoteTree() {
|
||||||
@ -484,7 +484,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
} else if (data.hitMode === "over") {
|
} else if (data.hitMode === "over") {
|
||||||
branchService.moveToParentNote(selectedBranchIds, node.data.branchId);
|
branchService.moveToParentNote(selectedBranchIds, node.data.branchId);
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Unknown hitMode=" + data.hitMode);
|
throw new Error(`Unknown hitMode=${data.hitMode}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,7 +676,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
|
const title = `${branch.prefix ? (`${branch.prefix} - `) : ""}${note.title}`;
|
||||||
|
|
||||||
node.data.isProtected = note.isProtected;
|
node.data.isProtected = note.isProtected;
|
||||||
node.data.noteType = note.type;
|
node.data.noteType = note.type;
|
||||||
@ -703,7 +703,7 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {
|
|||||||
throw new Error(`Branch "${branch.branchId}" has no child note "${branch.noteId}"`);
|
throw new Error(`Branch "${branch.branchId}" has no child note "${branch.noteId}"`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const title = (branch.prefix ? (branch.prefix + " - ") : "") + note.title;
|
const title = `${branch.prefix ? (`${branch.prefix} - `) : ""}${note.title}`;
|
||||||
|
|
||||||
const isFolder = note.isFolder();
|
const isFolder = note.isFolder();
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ export default class NoteTypeWidget extends NoteContextAwareWidget {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await server.put('notes/' + this.noteId + '/type', { type, mime });
|
await server.put(`notes/${this.noteId}/type`, { type, mime });
|
||||||
}
|
}
|
||||||
|
|
||||||
async confirmChangeIfContent() {
|
async confirmChangeIfContent() {
|
||||||
|
@ -98,12 +98,12 @@ export default class QuickSearchWidget extends BasicWidget {
|
|||||||
this.$dropdownMenu.empty();
|
this.$dropdownMenu.empty();
|
||||||
this.$dropdownMenu.append('<span class="dropdown-item disabled"><span class="bx bx-loader bx-spin"></span> Searching ...</span>');
|
this.$dropdownMenu.append('<span class="dropdown-item disabled"><span class="bx bx-loader bx-spin"></span> Searching ...</span>');
|
||||||
|
|
||||||
const {searchResultNoteIds, error} = await server.get('quick-search/' + encodeURIComponent(searchString));
|
const {searchResultNoteIds, error} = await server.get(`quick-search/${encodeURIComponent(searchString)}`);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
this.$searchString.tooltip({
|
this.$searchString.tooltip({
|
||||||
trigger: 'manual',
|
trigger: 'manual',
|
||||||
title: "Search error: " + error,
|
title: `Search error: ${error}`,
|
||||||
placement: 'right'
|
placement: 'right'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async refreshWithNote(note) {
|
async refreshWithNote(note) {
|
||||||
let editedNotes = await server.get('edited-notes/' + note.getLabelValue("dateNote"));
|
let editedNotes = await server.get(`edited-notes/${note.getLabelValue("dateNote")}`);
|
||||||
|
|
||||||
editedNotes = editedNotes.filter(n => n.noteId !== note.noteId);
|
editedNotes = editedNotes.filter(n => n.noteId !== note.noteId);
|
||||||
|
|
||||||
@ -69,7 +69,7 @@ export default class EditedNotesWidget extends CollapsibleWidget {
|
|||||||
const $item = $('<span class="edited-note-line">');
|
const $item = $('<span class="edited-note-line">');
|
||||||
|
|
||||||
if (editedNote.isDeleted) {
|
if (editedNote.isDeleted) {
|
||||||
const title = editedNote.title + " (deleted)";
|
const title = `${editedNote.title} (deleted)`;
|
||||||
$item.append(
|
$item.append(
|
||||||
$("<i>")
|
$("<i>")
|
||||||
.text(title)
|
.text(title)
|
||||||
|
@ -104,7 +104,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
formData.append('upload', fileToUpload);
|
formData.append('upload', fileToUpload);
|
||||||
|
|
||||||
const result = await $.ajax({
|
const result = await $.ajax({
|
||||||
url: baseApiUrl + 'notes/' + this.noteId + '/file',
|
url: `${baseApiUrl}notes/${this.noteId}/file`,
|
||||||
headers: await server.getHeaders(),
|
headers: await server.getHeaders(),
|
||||||
data: formData,
|
data: formData,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
@ -136,7 +136,7 @@ export default class FilePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
const noteComplement = await this.noteContext.getNoteComplement();
|
const noteComplement = await this.noteContext.getNoteComplement();
|
||||||
|
|
||||||
this.$fileSize.text(noteComplement.contentLength + " bytes");
|
this.$fileSize.text(`${noteComplement.contentLength} bytes`);
|
||||||
|
|
||||||
// open doesn't work for protected notes since it works through browser which isn't in protected session
|
// open doesn't work for protected notes since it works through browser which isn't in protected session
|
||||||
this.$openButton.toggle(!note.isProtected);
|
this.$openButton.toggle(!note.isProtected);
|
||||||
|
@ -88,7 +88,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
formData.append('upload', fileToUpload);
|
formData.append('upload', fileToUpload);
|
||||||
|
|
||||||
const result = await $.ajax({
|
const result = await $.ajax({
|
||||||
url: baseApiUrl + 'images/' + this.noteId,
|
url: `${baseApiUrl}images/${this.noteId}`,
|
||||||
headers: await server.getHeaders(),
|
headers: await server.getHeaders(),
|
||||||
data: formData,
|
data: formData,
|
||||||
type: 'PUT',
|
type: 'PUT',
|
||||||
@ -105,7 +105,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
this.refresh();
|
this.refresh();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastService.showError("Upload of a new image revision failed: " + result.message);
|
toastService.showError(`Upload of a new image revision failed: ${result.message}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -119,7 +119,7 @@ export default class ImagePropertiesWidget extends NoteContextAwareWidget {
|
|||||||
const noteComplement = await this.noteContext.getNoteComplement();
|
const noteComplement = await this.noteContext.getNoteComplement();
|
||||||
|
|
||||||
this.$fileName.text(attributeMap.originalFileName || "?");
|
this.$fileName.text(attributeMap.originalFileName || "?");
|
||||||
this.$fileSize.text(noteComplement.contentLength + " bytes");
|
this.$fileSize.text(`${noteComplement.contentLength} bytes`);
|
||||||
this.$fileType.text(note.mime);
|
this.$fileType.text(note.mime);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
|
|||||||
const subTreeResp = await server.get(`stats/subtree-size/${this.noteId}`);
|
const subTreeResp = await server.get(`stats/subtree-size/${this.noteId}`);
|
||||||
|
|
||||||
if (subTreeResp.subTreeNoteCount > 1) {
|
if (subTreeResp.subTreeNoteCount > 1) {
|
||||||
this.$subTreeSize.text("(subtree size: " + this.formatSize(subTreeResp.subTreeSize) + ` in ${subTreeResp.subTreeNoteCount} notes)`);
|
this.$subTreeSize.text(`(subtree size: ${this.formatSize(subTreeResp.subTreeSize)} in ${subTreeResp.subTreeNoteCount} notes)`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$subTreeSize.text("");
|
this.$subTreeSize.text("");
|
||||||
@ -133,7 +133,7 @@ export default class NoteInfoWidget extends NoteContextAwareWidget {
|
|||||||
this.$type.text(note.type);
|
this.$type.text(note.type);
|
||||||
|
|
||||||
if (note.mime) {
|
if (note.mime) {
|
||||||
this.$mime.text('(' + note.mime + ')');
|
this.$mime.text(`(${note.mime})`);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.$mime.empty();
|
this.$mime.empty();
|
||||||
|
@ -139,7 +139,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
$input.prop("type", "text");
|
$input.prop("type", "text");
|
||||||
|
|
||||||
// no need to await for this, can be done asynchronously
|
// no need to await for this, can be done asynchronously
|
||||||
server.get('attributes/values/' + encodeURIComponent(valueAttr.name)).then(attributeValues => {
|
server.get(`attributes/values/${encodeURIComponent(valueAttr.name)}`).then(attributeValues => {
|
||||||
if (attributeValues.length === 0) {
|
if (attributeValues.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -207,7 +207,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
.append($openButton));
|
.append($openButton));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ws.logError("Unknown labelType=" + definitionAttr.labelType);
|
ws.logError(`Unknown labelType=${definitionAttr.labelType}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (valueAttr.type === 'relation') {
|
else if (valueAttr.type === 'relation') {
|
||||||
@ -225,7 +225,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
$input.setSelectedNotePath(valueAttr.value);
|
$input.setSelectedNotePath(valueAttr.value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
ws.logError("Unknown attribute type=" + valueAttr.type);
|
ws.logError(`Unknown attribute type=${valueAttr.type}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -253,7 +253,7 @@ export default class PromotedAttributesWidget extends NoteContextAwareWidget {
|
|||||||
const attributeId = $input.attr("data-attribute-id");
|
const attributeId = $input.attr("data-attribute-id");
|
||||||
|
|
||||||
if (attributeId) {
|
if (attributeId) {
|
||||||
await server.remove("notes/" + this.noteId + "/attributes/" + attributeId, this.componentId);
|
await server.remove(`notes/${this.noteId}/attributes/${attributeId}`, this.componentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if it's the last one the create new empty form immediately
|
// if it's the last one the create new empty form immediately
|
||||||
|
@ -244,7 +244,7 @@ export default class SearchDefinitionWidget extends NoteContextAwareWidget {
|
|||||||
|
|
||||||
await appContext.tabManager.getActiveContext().setNote(notePath);
|
await appContext.tabManager.getActiveContext().setNote(notePath);
|
||||||
|
|
||||||
toastService.showMessage("Search note has been saved into " + await treeService.getNotePathTitle(notePath));
|
toastService.showMessage(`Search note has been saved into ${await treeService.getNotePathTitle(notePath)}`);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ export default class SimilarNotesWidget extends NoteContextAwareWidget {
|
|||||||
// remember which title was when we found the similar notes
|
// remember which title was when we found the similar notes
|
||||||
this.title = this.note.title;
|
this.title = this.note.title;
|
||||||
|
|
||||||
const similarNotes = await server.get('similar-notes/' + this.noteId);
|
const similarNotes = await server.get(`similar-notes/${this.noteId}`);
|
||||||
|
|
||||||
if (similarNotes.length === 0) {
|
if (similarNotes.length === 0) {
|
||||||
this.$similarNotesWrapper.empty().append("No similar notes found.");
|
this.$similarNotesWrapper.empty().append("No similar notes found.");
|
||||||
|
@ -61,7 +61,7 @@ export default class SearchString extends AbstractSearchOption {
|
|||||||
|
|
||||||
if (this.note.title.startsWith('Search: ')) {
|
if (this.note.title.startsWith('Search: ')) {
|
||||||
await server.put(`notes/${this.note.noteId}/title`, {
|
await server.put(`notes/${this.note.noteId}/title`, {
|
||||||
title: 'Search: ' + (searchString.length < 30 ? searchString : `${searchString.substr(0, 30)}…`)
|
title: `Search: ${searchString.length < 30 ? searchString : `${searchString.substr(0, 30)}…`}`
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, 1000);
|
}, 1000);
|
||||||
@ -74,7 +74,7 @@ export default class SearchString extends AbstractSearchOption {
|
|||||||
showSearchErrorEvent({error}) {
|
showSearchErrorEvent({error}) {
|
||||||
this.$searchString.tooltip({
|
this.$searchString.tooltip({
|
||||||
trigger: 'manual',
|
trigger: 'manual',
|
||||||
title: "Search error: " + error,
|
title: `Search error: ${error}`,
|
||||||
placement: 'bottom'
|
placement: 'bottom'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,11 +35,11 @@ export default class SharedInfoWidget extends NoteContextAwareWidget {
|
|||||||
const shareId = this.getShareId(note);
|
const shareId = this.getShareId(note);
|
||||||
|
|
||||||
if (syncServerHost) {
|
if (syncServerHost) {
|
||||||
link = syncServerHost + "/share/" + shareId;
|
link = `${syncServerHost}/share/${shareId}`;
|
||||||
this.$sharedText.text("This note is shared publicly on");
|
this.$sharedText.text("This note is shared publicly on");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
link = location.protocol + '//' + location.host + location.pathname + "share/" + shareId;
|
link = `${location.protocol}//${location.host}${location.pathname}share/${shareId}`;
|
||||||
this.$sharedText.text("This note is shared locally on");
|
this.$sharedText.text("This note is shared locally on");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +105,7 @@ export default class SyncStatusWidget extends BasicWidget {
|
|||||||
|
|
||||||
this.$widget.show();
|
this.$widget.show();
|
||||||
this.$widget.find('.sync-status-icon').hide();
|
this.$widget.find('.sync-status-icon').hide();
|
||||||
this.$widget.find('.sync-status-' + className).show();
|
this.$widget.find(`.sync-status-${className}`).show();
|
||||||
}
|
}
|
||||||
|
|
||||||
processMessage(message) {
|
processMessage(message) {
|
||||||
@ -134,7 +134,7 @@ export default class SyncStatusWidget extends BasicWidget {
|
|||||||
if (['unknown', 'in-progress'].includes(this.syncState)) {
|
if (['unknown', 'in-progress'].includes(this.syncState)) {
|
||||||
this.showIcon(this.syncState);
|
this.showIcon(this.syncState);
|
||||||
} else {
|
} else {
|
||||||
this.showIcon(this.syncState + '-' + (this.allChangesPushed ? 'no-changes' : 'with-changes'));
|
this.showIcon(`${this.syncState}-${this.allChangesPushed ? 'no-changes' : 'with-changes'}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -44,7 +44,7 @@ export default class EditableCodeTypeWidget extends TypeWidget {
|
|||||||
delete CodeMirror.keyMap.default["Alt-Left"];
|
delete CodeMirror.keyMap.default["Alt-Left"];
|
||||||
delete CodeMirror.keyMap.default["Alt-Right"];
|
delete CodeMirror.keyMap.default["Alt-Right"];
|
||||||
|
|
||||||
CodeMirror.modeURL = window.glob.assetPath + '/libraries/codemirror/mode/%N/%N.js';
|
CodeMirror.modeURL = `${window.glob.assetPath}/libraries/codemirror/mode/%N/%N.js`;
|
||||||
|
|
||||||
this.codeEditor = CodeMirror(this.$editor[0], {
|
this.codeEditor = CodeMirror(this.$editor[0], {
|
||||||
value: "",
|
value: "",
|
||||||
|
@ -249,9 +249,9 @@ export default class EditableTextTypeWidget extends AbstractTextTypeWidget {
|
|||||||
|
|
||||||
if (linkTitle) {
|
if (linkTitle) {
|
||||||
if (this.hasSelection()) {
|
if (this.hasSelection()) {
|
||||||
this.watchdog.editor.execute('link', '#' + notePath);
|
this.watchdog.editor.execute('link', `#${notePath}`);
|
||||||
} else {
|
} else {
|
||||||
await this.addLinkToEditor('#' + notePath, linkTitle);
|
await this.addLinkToEditor(`#${notePath}`, linkTitle);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -76,9 +76,9 @@ export default class EmptyTypeWidget extends TypeWidget {
|
|||||||
for (const workspaceNote of workspaceNotes) {
|
for (const workspaceNote of workspaceNotes) {
|
||||||
this.$workspaceNotes.append(
|
this.$workspaceNotes.append(
|
||||||
$('<div class="workspace-note">')
|
$('<div class="workspace-note">')
|
||||||
.append($("<div>").addClass(workspaceNote.getIcon() + " workspace-icon"))
|
.append($("<div>").addClass(`${workspaceNote.getIcon()} workspace-icon`))
|
||||||
.append($("<div>").text(workspaceNote.title))
|
.append($("<div>").text(workspaceNote.title))
|
||||||
.attr("title", "Enter workspace " + workspaceNote.title)
|
.attr("title", `Enter workspace ${workspaceNote.title}`)
|
||||||
.on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId}))
|
.on('click', () => this.triggerCommand('hoistNote', {noteId: workspaceNote.noteId}))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -65,19 +65,19 @@ export default class FileTypeWidget extends TypeWidget {
|
|||||||
this.$previewContent.text(noteComplement.content);
|
this.$previewContent.text(noteComplement.content);
|
||||||
}
|
}
|
||||||
else if (note.mime === 'application/pdf') {
|
else if (note.mime === 'application/pdf') {
|
||||||
this.$pdfPreview.show().attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open"));
|
this.$pdfPreview.show().attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open`));
|
||||||
}
|
}
|
||||||
else if (note.mime.startsWith('video/')) {
|
else if (note.mime.startsWith('video/')) {
|
||||||
this.$videoPreview
|
this.$videoPreview
|
||||||
.show()
|
.show()
|
||||||
.attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial"))
|
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
|
||||||
.attr("type", this.note.mime)
|
.attr("type", this.note.mime)
|
||||||
.css("width", this.$widget.width());
|
.css("width", this.$widget.width());
|
||||||
}
|
}
|
||||||
else if (note.mime.startsWith('audio/')) {
|
else if (note.mime.startsWith('audio/')) {
|
||||||
this.$audioPreview
|
this.$audioPreview
|
||||||
.show()
|
.show()
|
||||||
.attr("src", openService.getUrlForDownload("api/notes/" + this.noteId + "/open-partial"))
|
.attr("src", openService.getUrlForDownload(`api/notes/${this.noteId}/open-partial`))
|
||||||
.attr("type", this.note.mime)
|
.attr("type", this.note.mime)
|
||||||
.css("width", this.$widget.width());
|
.css("width", this.$widget.width());
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,10 @@ class ImageTypeWidget extends TypeWidget {
|
|||||||
this.$widget = $(TPL);
|
this.$widget = $(TPL);
|
||||||
this.$imageWrapper = this.$widget.find('.note-detail-image-wrapper');
|
this.$imageWrapper = this.$widget.find('.note-detail-image-wrapper');
|
||||||
this.$imageView = this.$widget.find('.note-detail-image-view')
|
this.$imageView = this.$widget.find('.note-detail-image-view')
|
||||||
.attr("id", "image-view-" + utils.randomString(10));
|
.attr("id", `image-view-${utils.randomString(10)}`);
|
||||||
|
|
||||||
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
|
libraryLoader.requireLibrary(libraryLoader.WHEEL_ZOOM).then(() => {
|
||||||
WZoom.create('#' + this.$imageView.attr("id"), {
|
WZoom.create(`#${this.$imageView.attr("id")}`, {
|
||||||
maxScale: 10,
|
maxScale: 10,
|
||||||
speed: 20,
|
speed: 20,
|
||||||
zoomOnClick: false
|
zoomOnClick: false
|
||||||
|
@ -24,7 +24,7 @@ export default class DatabaseIntegrityCheckOptions extends OptionsWidget {
|
|||||||
toastService.showMessage("Integrity check succeeded - no problems found.");
|
toastService.showMessage("Integrity check succeeded - no problems found.");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastService.showMessage("Integrity check failed: " + JSON.stringify(results, null, 2), 15000);
|
toastService.showMessage(`Integrity check failed: ${JSON.stringify(results, null, 2)}`, 15000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -167,8 +167,8 @@ export default class FontsOptions extends OptionsWidget {
|
|||||||
];
|
];
|
||||||
|
|
||||||
for (const optionName of optionsToSave) {
|
for (const optionName of optionsToSave) {
|
||||||
this['$' + optionName].on('change', () =>
|
this[`$${optionName}`].on('change', () =>
|
||||||
this.updateOption(optionName, this['$' + optionName].val()));
|
this.updateOption(optionName, this[`$${optionName}`].val()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,7 +28,7 @@ export default class ThemeOptions extends OptionsWidget {
|
|||||||
this.$themeSelect.on('change', async () => {
|
this.$themeSelect.on('change', async () => {
|
||||||
const newTheme = this.$themeSelect.val();
|
const newTheme = this.$themeSelect.val();
|
||||||
|
|
||||||
await server.put('options/theme/' + newTheme);
|
await server.put(`options/theme/${newTheme}`);
|
||||||
|
|
||||||
utils.reloadFrontendApp("theme change");
|
utils.reloadFrontendApp("theme change");
|
||||||
});
|
});
|
||||||
|
@ -48,7 +48,7 @@ export default class BackupOptions extends OptionsWidget {
|
|||||||
this.$backupDatabaseButton.on('click', async () => {
|
this.$backupDatabaseButton.on('click', async () => {
|
||||||
const {backupFile} = await server.post('database/backup-database');
|
const {backupFile} = await server.post('database/backup-database');
|
||||||
|
|
||||||
toastService.showMessage("Database has been backed up to " + backupFile, 10000);
|
toastService.showMessage(`Database has been backed up to ${backupFile}`, 10000);
|
||||||
});
|
});
|
||||||
|
|
||||||
this.$dailyBackupEnabled = this.$widget.find(".daily-backup-enabled");
|
this.$dailyBackupEnabled = this.$widget.find(".daily-backup-enabled");
|
||||||
|
@ -106,7 +106,7 @@ export default class KeyboardShortcutsOptions extends OptionsWidget {
|
|||||||
.map(shortcut => shortcut.replace("+Comma", "+,"))
|
.map(shortcut => shortcut.replace("+Comma", "+,"))
|
||||||
.filter(shortcut => !!shortcut);
|
.filter(shortcut => !!shortcut);
|
||||||
|
|
||||||
const optionName = 'keyboardShortcuts' + actionName.substr(0, 1).toUpperCase() + actionName.substr(1);
|
const optionName = `keyboardShortcuts${actionName.substr(0, 1).toUpperCase()}${actionName.substr(1)}`;
|
||||||
|
|
||||||
this.updateOption(optionName, JSON.stringify(shortcuts));
|
this.updateOption(optionName, JSON.stringify(shortcuts));
|
||||||
});
|
});
|
||||||
|
@ -59,7 +59,7 @@ export default class SyncOptions extends OptionsWidget {
|
|||||||
toastService.showMessage(result.message);
|
toastService.showMessage(result.message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
toastService.showError("Sync server handshake failed, error: " + result.message);
|
toastService.showError(`Sync server handshake failed, error: ${result.message}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
noteIdToId(noteId) {
|
noteIdToId(noteId) {
|
||||||
return "rel-map-note-" + noteId;
|
return `rel-map-note-${noteId}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
idToNoteId(id) {
|
idToNoteId(id) {
|
||||||
@ -484,8 +484,8 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
.prop("id", this.noteIdToId(noteId))
|
.prop("id", this.noteIdToId(noteId))
|
||||||
.append($("<span>").addClass("title").append($link))
|
.append($("<span>").addClass("title").append($link))
|
||||||
.append($("<div>").addClass("endpoint").attr("title", "Start dragging relations from here and drop them on another note."))
|
.append($("<div>").addClass("endpoint").attr("title", "Start dragging relations from here and drop them on another note."))
|
||||||
.css("left", x + "px")
|
.css("left", `${x}px`)
|
||||||
.css("top", y + "px");
|
.css("top", `${y}px`);
|
||||||
|
|
||||||
this.jsPlumbInstance.getContainer().appendChild($noteBox[0]);
|
this.jsPlumbInstance.getContainer().appendChild($noteBox[0]);
|
||||||
|
|
||||||
@ -537,7 +537,7 @@ export default class RelationMapTypeWidget extends TypeWidget {
|
|||||||
const matches = transform.match(matrixRegex);
|
const matches = transform.match(matrixRegex);
|
||||||
|
|
||||||
if (!matches) {
|
if (!matches) {
|
||||||
throw new Error("Cannot match transform: " + transform);
|
throw new Error(`Cannot match transform: ${transform}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
return matches[1];
|
return matches[1];
|
||||||
|
@ -38,7 +38,7 @@ function getRecentNotes(activeNoteId) {
|
|||||||
const hoistedNoteId = cls.getHoistedNoteId();
|
const hoistedNoteId = cls.getHoistedNoteId();
|
||||||
if (hoistedNoteId !== 'root') {
|
if (hoistedNoteId !== 'root') {
|
||||||
extraCondition = `AND recent_notes.notePath LIKE ?`;
|
extraCondition = `AND recent_notes.notePath LIKE ?`;
|
||||||
params.push('%' + hoistedNoteId + '%');
|
params.push(`%${hoistedNoteId}%`);
|
||||||
}
|
}
|
||||||
|
|
||||||
const recentNotes = becca.getRecentNotesFromQuery(`
|
const recentNotes = becca.getRecentNotesFromQuery(`
|
||||||
|
@ -68,7 +68,7 @@ function addClipping(req) {
|
|||||||
|
|
||||||
const existingContent = clippingNote.getContent();
|
const existingContent = clippingNote.getContent();
|
||||||
|
|
||||||
clippingNote.setContent(existingContent + (existingContent.trim() ? "<br/>" : "") + rewrittenContent);
|
clippingNote.setContent(`${existingContent}${existingContent.trim() ? "<br/>" : ""}${rewrittenContent}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
noteId: clippingNote.noteId
|
noteId: clippingNote.noteId
|
||||||
@ -79,7 +79,7 @@ function createNote(req) {
|
|||||||
let {title, content, pageUrl, images, clipType} = req.body;
|
let {title, content, pageUrl, images, clipType} = req.body;
|
||||||
|
|
||||||
if (!title || !title.trim()) {
|
if (!title || !title.trim()) {
|
||||||
title = "Clipped note from " + pageUrl;
|
title = `Clipped note from ${pageUrl}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
const clipperInbox = getClipperInboxNote();
|
const clipperInbox = getClipperInboxNote();
|
||||||
@ -123,7 +123,7 @@ function processContent(images, note, content) {
|
|||||||
? dataUrl.substr(0, Math.min(100, dataUrl.length))
|
? dataUrl.substr(0, Math.min(100, dataUrl.length))
|
||||||
: "null";
|
: "null";
|
||||||
|
|
||||||
log.info("Image could not be recognized as data URL: " + excerpt);
|
log.info(`Image could not be recognized as data URL: ${excerpt}`);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ function vacuumDatabase() {
|
|||||||
function checkIntegrity() {
|
function checkIntegrity() {
|
||||||
const results = sql.getRows("PRAGMA integrity_check");
|
const results = sql.getRows("PRAGMA integrity_check");
|
||||||
|
|
||||||
log.info("Integrity check result: " + JSON.stringify(results));
|
log.info(`Integrity check result: ${JSON.stringify(results)}`);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
results
|
results
|
||||||
|
@ -18,7 +18,7 @@ function returnImage(req, res) {
|
|||||||
}
|
}
|
||||||
else if (image.isDeleted || image.data === null) {
|
else if (image.isDeleted || image.data === null) {
|
||||||
res.set('Content-Type', 'image/png');
|
res.set('Content-Type', 'image/png');
|
||||||
return res.send(fs.readFileSync(RESOURCE_DIR + '/db/image-deleted.png'));
|
return res.send(fs.readFileSync(`${RESOURCE_DIR}/db/image-deleted.png`));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,7 +81,7 @@ function updateImage(req) {
|
|||||||
if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
|
if (!["image/png", "image/jpeg", "image/gif", "image/webp", "image/svg+xml"].includes(file.mimetype)) {
|
||||||
return {
|
return {
|
||||||
uploaded: false,
|
uploaded: false,
|
||||||
message: "Unknown image type: " + file.mimetype
|
message: `Unknown image type: ${file.mimetype}`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ async function importToBranch(req) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (e) {
|
catch (e) {
|
||||||
const message = "Import failed with following error: '" + e.message + "'. More details might be in the logs.";
|
const message = `Import failed with following error: '${e.message}'. More details might be in the logs.`;
|
||||||
taskContext.reportError(message);
|
taskContext.reportError(message);
|
||||||
|
|
||||||
log.error(message + e.stack);
|
log.error(message + e.stack);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user