1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-06 09:19:22 +02:00

All: Refactor Markdown rendering (#1315)

* Refactoring MdToHtml to avoid manually rendering tokens

* Minor fix

* Fixed loading of resources

* Handle clicking on checkboxes

* Added back Katex support

* Fixed issues with Katex and note rendering

* Added back support for links

* Restored code block highlighting support

* clean up

* Applying update to mobile

* Fixed handling of links and cleaned up to share more code between mobile and desktop

* Restored content caching and improved handling of additional assets

* Clean up and a few fixes

* Applied more updates to mobile and added code highlighting support
This commit is contained in:
Laurent Cozic
2019-03-08 17:14:17 +00:00
committed by GitHub
parent 5719ae495a
commit 9289dbdf77
42 changed files with 1223 additions and 1468 deletions

View File

@@ -6,6 +6,7 @@ const EventEmitter = require('events');
const { splitCommandString } = require('lib/string-utils');
const { fileExtension } = require('lib/path-utils');
const spawn = require('child_process').spawn;
const chokidar = require('chokidar');
class ExternalEditWatcher {
@@ -15,6 +16,7 @@ class ExternalEditWatcher {
this.watcher_ = null;
this.eventEmitter_ = new EventEmitter();
this.skipNextChangeEvent_ = {};
this.chokidar_ = chokidar;
}
static instance() {
@@ -39,14 +41,16 @@ class ExternalEditWatcher {
return this.logger_;
}
async preload() {
// Chokidar is extremely slow to load since Electron 4 - it takes over 4 seconds
// on my computer. So load it in the background.
setTimeout(() => {
if (this.chokidar_) return;
this.chokidar_ = require('chokidar');
}, 1000);
}
// async preload() {
// // Chokidar is extremely slow to load since Electron 4 - it takes over 4 seconds
// // on my computer. So load it in the background.
// setTimeout(() => {
// if (this.chokidar_) return;
// const startTime = Date.now();
// this.chokidar_ = require('chokidar');
// console.info('Chokidar load time:', Date.now() - startTime);
// }, 1000);
// }
watch(fileToWatch) {
if (!this.chokidar_) return;

View File

@@ -0,0 +1,38 @@
const BaseItem = require('lib/models/BaseItem');
class ModelCache {
constructor() {
this.cache_ = {};
}
async byIds(itemType, ids) {
const ModelClass = BaseItem.getClassByItemType(itemType);
const output = [];
const remainingIds = [];
for (let i = 0; i < ids.length; i++) {
const id = ids[i];
if (!this.cache_[id]) {
remainingIds.push(id);
} else {
output.push(this.cache_[id].model);
}
}
const models = await ModelClass.byIds(remainingIds);
for (let i = 0; i < models.length; i++) {
this.cache_[models[i].id] = {
model: models[i],
timestamp: Date.now(),
}
output.push(models[i]);
}
return output;
}
}
module.exports = ModelCache;

View File

@@ -1,5 +1,4 @@
const Resource = require('lib/models/Resource');
const ResourceLocalState = require('lib/models/ResourceLocalState');
const BaseService = require('lib/services/BaseService');
const BaseSyncTarget = require('lib/BaseSyncTarget');
const { Logger } = require('lib/logger.js');
@@ -176,7 +175,7 @@ class ResourceFetcher extends BaseService {
}
async start() {
await ResourceLocalState.resetStartedFetchStatus();
await Resource.resetStartedFetchStatus();
this.autoAddResources(10);
}
@@ -193,7 +192,7 @@ class ResourceFetcher extends BaseService {
}
async fetchAll() {
await ResourceLocalState.resetStartedFetchStatus();
await Resource.resetStartedFetchStatus();
this.autoAddResources(null);
}