yarle-evernote-to-md
Version:
Yet Another Rope Ladder from Evernote
57 lines • 2.34 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RuntimePropertiesSingleton = void 0;
const lodash_1 = require("lodash");
const getGuid = (linkItem) => {
const linkSpl = (0, lodash_1.cloneDeep)(linkItem.url).split('/').reverse().filter(item => !!item);
return (linkSpl.length > 1)
? linkSpl[1]
: linkSpl[0];
};
class RuntimePropertiesSingleton {
constructor() {
this.noteIdNameMap = {};
this.noteIdNameTOCMap = {};
}
static getInstance() {
if (!RuntimePropertiesSingleton.instance) {
RuntimePropertiesSingleton.instance = new RuntimePropertiesSingleton();
}
return RuntimePropertiesSingleton.instance;
}
addItemToMap(linkItem) {
this.noteIdNameMap[linkItem.id] = Object.assign(Object.assign({}, this.noteIdNameMap[linkItem.id]), { url: linkItem.url, guid: getGuid(linkItem), title: linkItem.title, noteName: this.currentNoteName, notebookName: this.currentNotebookName, uniqueEnd: linkItem.uniqueEnd });
}
addItemToTOCMap(linkItem) {
this.noteIdNameTOCMap[linkItem.id] = Object.assign(Object.assign({}, this.noteIdNameMap[linkItem.id]), { title: linkItem.title, url: linkItem.url, guid: getGuid(linkItem), noteName: this.currentNoteName, notebookName: this.currentNotebookName, uniqueEnd: linkItem.uniqueEnd });
}
getNoteIdNameMap() {
return this.noteIdNameMap;
}
getNoteIdNameTOCMap() {
return this.noteIdNameTOCMap;
}
getAllNoteIdNameMap() {
return Object.assign(Object.assign({}, this.noteIdNameMap), this.noteIdNameTOCMap);
}
getNoteIdNameMapByNoteTitle(noteTitle) {
return Object.values(this.getAllNoteIdNameMap()).filter(noteIdName => noteIdName.title === noteTitle);
}
setCurrentNotebookName(currentNotebookName) {
this.currentNotebookName = currentNotebookName;
}
setCurrentNoteName(currentNoteName) {
this.currentNoteName = currentNoteName;
}
getCurrentNoteName() {
return this.currentNoteName;
}
getCurrentNotePath() {
return this.currentNotePath;
}
setCurrentNotePath(value) {
this.currentNotePath = value;
}
}
exports.RuntimePropertiesSingleton = RuntimePropertiesSingleton;
//# sourceMappingURL=runtime-properties.js.map