yarle-evernote-to-md
Version:
Yet Another Rope Ladder from Evernote
54 lines • 2.77 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Tana = void 0;
const create_tana_output_1 = require("./../utils/tana/create-tana-output");
const StandardMD_1 = require("./StandardMD");
const convert_to_tana_node_1 = require("./../utils/tana/convert-to-tana-node");
const save_tana_file_1 = require("./../utils/save-tana-file");
const constants_1 = require("./../constants");
class Tana extends StandardMD_1.StandardMD {
constructor() {
super();
this.languageItems = {
bold: '**',
italic: '__',
highlight: '^^',
strikethrough: '~~',
listItem: ''
};
this.codeBlock = '<YARLE_TANA_CODE_BLOCK>';
this.postProcess = async (options, outputNotebookFolders) => {
(0, create_tana_output_1.createTanaOutput)(options, outputNotebookFolders);
};
this.noteExtension = '.json';
this.noteProcess = (options, data, note) => {
const tanaJson = (0, convert_to_tana_node_1.convert2TanaNode)(data);
(0, save_tana_file_1.saveTanaFile)(tanaJson, note);
};
this.tagProcess = (content, tasks, currentTaskPlaceholder, updatedContent) => {
var _a, _b, _c, _d, _e, _f;
const tanaNote = JSON.parse(content);
const rootTaskChild = (_b = (_a = tanaNote.nodes) === null || _a === void 0 ? void 0 : _a[0].children) === null || _b === void 0 ? void 0 : _b.find((child) => child.name === currentTaskPlaceholder);
if (rootTaskChild) {
for (const taskItem of tasks.values()) {
// split by tasks
const todoState = taskItem.startsWith(constants_1.checkboxTodo) ? 'todo' : 'done';
(_d = (_c = tanaNote.nodes) === null || _c === void 0 ? void 0 : _c[0].children) === null || _d === void 0 ? void 0 : _d.push({
uid: 'uuid' + Math.random(),
createdAt: rootTaskChild.createdAt,
editedAt: rootTaskChild.editedAt,
type: 'node',
name: (0, convert_to_tana_node_1.cleanTanaContent)(taskItem, todoState === 'todo' ? constants_1.checkboxTodo : constants_1.checkboxDone),
todoState: todoState,
refs: [],
});
}
(_e = tanaNote.nodes) === null || _e === void 0 ? void 0 : _e[0].children.splice((_f = tanaNote.nodes) === null || _f === void 0 ? void 0 : _f[0].children.indexOf(rootTaskChild), 1);
return JSON.stringify(tanaNote);
}
return updatedContent;
};
}
}
exports.Tana = Tana;
//# sourceMappingURL=Tana.js.map