2018-03-26 07:49:33 +08:00
|
|
|
import addLinkDialog from '../dialogs/add_link.js';
|
|
|
|
import jumpToNoteDialog from '../dialogs/jump_to_note.js';
|
2018-03-26 01:02:39 +08:00
|
|
|
import labelsDialog from '../dialogs/labels.js';
|
2018-03-26 08:52:38 +08:00
|
|
|
import noteRevisionsDialog from '../dialogs/note_revisions.js';
|
2018-03-26 07:49:33 +08:00
|
|
|
import noteSourceDialog from '../dialogs/note_source.js';
|
|
|
|
import recentChangesDialog from '../dialogs/recent_changes.js';
|
|
|
|
import recentNotesDialog from '../dialogs/recent_notes.js';
|
2018-04-02 05:41:28 +08:00
|
|
|
import optionsDialog from '../dialogs/options.js';
|
2018-03-26 07:49:33 +08:00
|
|
|
import sqlConsoleDialog from '../dialogs/sql_console.js';
|
2018-03-24 23:18:46 +08:00
|
|
|
|
2018-03-25 23:09:17 +08:00
|
|
|
import cloning from './cloning.js';
|
|
|
|
import contextMenu from './context_menu.js';
|
|
|
|
import dragAndDropSetup from './drag_and_drop.js';
|
|
|
|
import exportService from './export.js';
|
|
|
|
import link from './link.js';
|
2018-03-27 12:22:02 +08:00
|
|
|
import messagingService from './messaging.js';
|
2018-03-26 08:18:08 +08:00
|
|
|
import noteDetailService from './note_detail.js';
|
2018-03-25 23:09:17 +08:00
|
|
|
import noteType from './note_type.js';
|
|
|
|
import protected_session from './protected_session.js';
|
2018-06-05 07:48:02 +08:00
|
|
|
import searchNotesService from './search_notes.js';
|
2018-03-25 23:09:17 +08:00
|
|
|
import ScriptApi from './script_api.js';
|
|
|
|
import ScriptContext from './script_context.js';
|
|
|
|
import sync from './sync.js';
|
2018-03-26 07:49:33 +08:00
|
|
|
import treeService from './tree.js';
|
2018-04-02 08:33:10 +08:00
|
|
|
import treeChanges from './branches.js';
|
2018-03-25 23:09:17 +08:00
|
|
|
import treeUtils from './tree_utils.js';
|
|
|
|
import utils from './utils.js';
|
2018-03-26 08:18:08 +08:00
|
|
|
import server from './server.js';
|
2018-03-27 10:29:14 +08:00
|
|
|
import entrypoints from './entrypoints.js';
|
|
|
|
import tooltip from './tooltip.js';
|
|
|
|
import bundle from "./bundle.js";
|
|
|
|
import treeCache from "./tree_cache.js";
|
2018-03-28 10:42:46 +08:00
|
|
|
import libraryLoader from "./library_loader.js";
|
2018-03-24 23:18:46 +08:00
|
|
|
|
2018-03-26 08:18:08 +08:00
|
|
|
// required for CKEditor image upload plugin
|
|
|
|
window.glob.getCurrentNode = treeService.getCurrentNode;
|
|
|
|
window.glob.getHeaders = server.getHeaders;
|
2018-05-26 22:04:40 +08:00
|
|
|
window.glob.showAddLinkDialog = addLinkDialog.showDialog;
|
2018-03-26 08:18:08 +08:00
|
|
|
|
|
|
|
// required for ESLint plugin
|
|
|
|
window.glob.getCurrentNote = noteDetailService.getCurrentNote;
|
2018-03-28 10:42:46 +08:00
|
|
|
window.glob.requireLibrary = libraryLoader.requireLibrary;
|
|
|
|
window.glob.ESLINT = libraryLoader.ESLINT;
|
2018-03-26 08:18:08 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
window.onerror = function (msg, url, lineNo, columnNo, error) {
|
|
|
|
const string = msg.toLowerCase();
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
let message = "Uncaught error: ";
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
if (string.indexOf("script error") > -1){
|
|
|
|
message += 'No details available';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
message += [
|
|
|
|
'Message: ' + msg,
|
|
|
|
'URL: ' + url,
|
|
|
|
'Line: ' + lineNo,
|
|
|
|
'Column: ' + columnNo,
|
|
|
|
'Error object: ' + JSON.stringify(error)
|
|
|
|
].join(' - ');
|
|
|
|
}
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
messagingService.logError(message);
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
return false;
|
|
|
|
};
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
$("#logout-button").toggle(!utils.isElectron());
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
if (utils.isElectron()) {
|
|
|
|
require('electron').ipcRenderer.on('create-day-sub-note', async function(event, parentNoteId) {
|
|
|
|
// this might occur when day note had to be created
|
|
|
|
if (!await treeCache.getNote(parentNoteId)) {
|
|
|
|
await treeService.reload();
|
|
|
|
}
|
2018-03-26 07:49:33 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
await treeService.activateNode(parentNoteId);
|
2018-03-24 23:18:46 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
setTimeout(() => {
|
|
|
|
const node = treeService.getCurrentNode();
|
2018-03-24 23:18:46 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
treeService.createNote(node, node.data.noteId, 'into', node.data.isProtected);
|
|
|
|
}, 500);
|
|
|
|
});
|
|
|
|
}
|
2018-03-26 10:37:02 +08:00
|
|
|
|
2018-03-27 10:29:14 +08:00
|
|
|
treeService.showTree();
|
|
|
|
|
|
|
|
entrypoints.registerEntrypoints();
|
|
|
|
|
|
|
|
tooltip.setupTooltip();
|
|
|
|
|
2018-04-05 11:51:47 +08:00
|
|
|
bundle.executeStartupBundles();
|