mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-15 09:04:04 +02:00
08af9de190
* Started revisions support * More rev changes * More rev changes * More revs changes * Fixed deletion algorithm * More tests and moved updated time to separate field * Display info when restoring note * Better handling of existing notes * wip * Further improvements and fixed tests * Better handling of changes created via sync * Enable chokidar again * Testing special case * Further improved logic to handle notes that existed before the revision service * Added tests * Better handling of encrypted revisions * Improved handling of deleted note revisions by moving logic to collectRevision * Improved handling of old notes by moving logic to collectRevision() * Handle case when deleting revisions while one is still encrypted * UI tweaks * Added revision service to mobile app * Fixed config screens on mobile and desktop * Enabled revisions on CLI app
82 lines
3.3 KiB
JavaScript
82 lines
3.3 KiB
JavaScript
// This is the initialization for the Electron RENDERER process
|
|
|
|
// Make it possible to require("/lib/...") without specifying full path
|
|
require('app-module-path').addPath(__dirname);
|
|
|
|
// Disable React message in console "Download the React DevTools for a better development experience"
|
|
// https://stackoverflow.com/questions/42196819/disable-hide-download-the-react-devtools#42196820
|
|
__REACT_DEVTOOLS_GLOBAL_HOOK__ = {
|
|
supportsFiber: true,
|
|
inject: function() {},
|
|
onCommitFiberRoot: function() {},
|
|
onCommitFiberUnmount: function() {},
|
|
};
|
|
|
|
const { app } = require('./app.js');
|
|
const Folder = require('lib/models/Folder.js');
|
|
const Resource = require('lib/models/Resource.js');
|
|
const BaseItem = require('lib/models/BaseItem.js');
|
|
const Note = require('lib/models/Note.js');
|
|
const Tag = require('lib/models/Tag.js');
|
|
const NoteTag = require('lib/models/NoteTag.js');
|
|
const MasterKey = require('lib/models/MasterKey');
|
|
const Setting = require('lib/models/Setting.js');
|
|
const Revision = require('lib/models/Revision.js');
|
|
const { Logger } = require('lib/logger.js');
|
|
const { FsDriverNode } = require('lib/fs-driver-node.js');
|
|
const { shimInit } = require('lib/shim-init-node.js');
|
|
const EncryptionService = require('lib/services/EncryptionService');
|
|
const { bridge } = require('electron').remote.require('./bridge');
|
|
const { FileApiDriverLocal } = require('lib/file-api-driver-local.js');
|
|
|
|
const fsDriver = new FsDriverNode();
|
|
Logger.fsDriver_ = fsDriver;
|
|
Resource.fsDriver_ = fsDriver;
|
|
EncryptionService.fsDriver_ = fsDriver;
|
|
FileApiDriverLocal.fsDriver_ = fsDriver;
|
|
|
|
// That's not good, but it's to avoid circular dependency issues
|
|
// in the BaseItem class.
|
|
BaseItem.loadClass('Note', Note);
|
|
BaseItem.loadClass('Folder', Folder);
|
|
BaseItem.loadClass('Resource', Resource);
|
|
BaseItem.loadClass('Tag', Tag);
|
|
BaseItem.loadClass('NoteTag', NoteTag);
|
|
BaseItem.loadClass('MasterKey', MasterKey);
|
|
BaseItem.loadClass('Revision', Revision);
|
|
|
|
Setting.setConstant('appId', 'net.cozic.joplin-desktop');
|
|
Setting.setConstant('appType', 'desktop');
|
|
|
|
shimInit();
|
|
|
|
// Disable drag and drop of links inside application (which would
|
|
// open it as if the whole app was a browser)
|
|
document.addEventListener('dragover', event => event.preventDefault());
|
|
document.addEventListener('drop', event => event.preventDefault());
|
|
|
|
// Disable middle-click (which would open a new browser window, but we don't want this)
|
|
document.addEventListener('auxclick', event => event.preventDefault());
|
|
|
|
// Each link (rendered as a button or list item) has its own custom click event
|
|
// so disable the default. In particular this will disable Ctrl+Clicking a link
|
|
// which would open a new browser window.
|
|
document.addEventListener('click', (event) => event.preventDefault());
|
|
|
|
app().start(bridge().processArgv()).then(() => {
|
|
require('./gui/Root.min.js');
|
|
}).catch((error) => {
|
|
if (error.code == 'flagError') {
|
|
bridge().showErrorMessageBox(error.message);
|
|
} else {
|
|
// If something goes wrong at this stage we don't have a console or a log file
|
|
// so display the error in a message box.
|
|
let msg = ['Fatal error:', error.message];
|
|
if (error.fileName) msg.push(error.fileName);
|
|
if (error.lineNumber) msg.push(error.lineNumber);
|
|
if (error.stack) msg.push(error.stack);
|
|
bridge().showErrorMessageBox(msg.join('\n\n'));
|
|
}
|
|
|
|
bridge().electronApp().exit(1);
|
|
}); |