You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
86 lines
11 KiB
86 lines
11 KiB
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ROLLUP
|
|
if you want to view the source visit the plugins github repository
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
var obsidian = require('obsidian');
|
|
|
|
//string to array of classes
|
|
const arrayToClasses = (input) => {
|
|
input = input.trim();
|
|
if (input[0] != "[" || input[input.length - 1] != "]")
|
|
return [];
|
|
return input
|
|
.substring(1, input.length - 1)
|
|
.trim()
|
|
.split(/\s*,\s*/);
|
|
};
|
|
class EventFactory {
|
|
constructor(root, sourcePath) {
|
|
this.root = root;
|
|
this.sourcePath = sourcePath;
|
|
}
|
|
//remove first child's top margin and last child's bottom margin
|
|
regulate(component) {
|
|
let aux = component.lastChild;
|
|
aux.style.marginBottom = "0";
|
|
aux = component.firstChild;
|
|
aux.style.marginTop = "0";
|
|
}
|
|
create(time, title, description) {
|
|
let timeEl = this.root.createDiv({ cls: "time" });
|
|
let infoEl = this.root.createDiv({ cls: "info" });
|
|
let titleEl = infoEl.createDiv({ cls: "title" });
|
|
let descriptionEl = infoEl.createDiv({ cls: "description" });
|
|
obsidian.MarkdownRenderer.renderMarkdown(time, timeEl, this.sourcePath, null);
|
|
obsidian.MarkdownRenderer.renderMarkdown(title, titleEl, this.sourcePath, null);
|
|
obsidian.MarkdownRenderer.renderMarkdown(description, descriptionEl, this.sourcePath, null);
|
|
this.regulate(descriptionEl);
|
|
this.regulate(timeEl);
|
|
this.regulate(titleEl);
|
|
}
|
|
}
|
|
const codeBlockHandler = (source, el, ctx) => {
|
|
//Initial State
|
|
el.addClass("timeline");
|
|
let ef = new EventFactory(el, ctx.sourcePath);
|
|
//source to events
|
|
const events = source
|
|
.split(/^\s*\+ ?/gm)
|
|
.map((event) => (event.trim().length != 0 ? event : "\u200B"));
|
|
for (let elClass of arrayToClasses(events[0]))
|
|
el.addClass(elClass);
|
|
const incompleteCounter = (events.length - 1) % 3;
|
|
const completeCounter = events.length - 1 - incompleteCounter;
|
|
//build it
|
|
el.createDiv({
|
|
cls: "main-line",
|
|
attr: {
|
|
style: `grid-row-end: ${completeCounter / 3 + 1 + (incompleteCounter != 0 ? 1 : 0)}`,
|
|
},
|
|
});
|
|
for (let i = 1; i < completeCounter; i += 3) {
|
|
ef.create(events[i], events[i + 1], events[i + 2]);
|
|
}
|
|
switch (incompleteCounter) {
|
|
case 1:
|
|
ef.create(events[completeCounter + 1], "", "");
|
|
return;
|
|
case 2:
|
|
ef.create(events[completeCounter + 1], events[completeCounter + 2], "");
|
|
return;
|
|
default:
|
|
return;
|
|
}
|
|
};
|
|
class MyPlugin extends obsidian.Plugin {
|
|
onload() {
|
|
this.registerMarkdownCodeBlockProcessor("timeline", codeBlockHandler);
|
|
}
|
|
}
|
|
|
|
module.exports = MyPlugin;
|
|
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWFpbi5qcyIsInNvdXJjZXMiOlsibWFpbi50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQge1xyXG5cdFBsdWdpbixcclxuXHRNYXJrZG93blBvc3RQcm9jZXNzb3JDb250ZXh0LFxyXG5cdE1hcmtkb3duUmVuZGVyZXIsXHJcbn0gZnJvbSBcIm9ic2lkaWFuXCI7XHJcblxyXG4vL3N0cmluZyB0byBhcnJheSBvZiBjbGFzc2VzXHJcbmNvbnN0IGFycmF5VG9DbGFzc2VzID0gKGlucHV0OiBzdHJpbmcpOiBzdHJpbmdbXSA9PiB7XHJcblx0aW5wdXQgPSBpbnB1dC50cmltKCk7XHJcblx0aWYgKGlucHV0WzBdICE9IFwiW1wiIHx8IGlucHV0W2lucHV0Lmxlbmd0aCAtIDFdICE9IFwiXVwiKSByZXR1cm4gW107XHJcblxyXG5cdHJldHVybiBpbnB1dFxyXG5cdFx0LnN1YnN0cmluZygxLCBpbnB1dC5sZW5ndGggLSAxKVxyXG5cdF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