vault backup: 2025-08-23 09:34:42
This commit is contained in:
1 parent
f70f856df4
commit
a8a941274b
10 files changed
+428
-14
No files matched your search
+123
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
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');
|
||||
|
||||
/******************************************************************************
|
||||
Copyright (c) Microsoft Corporation.
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
||||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
||||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
||||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
||||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
||||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
PERFORMANCE OF THIS SOFTWARE.
|
||||
***************************************************************************** */
|
||||
|
||||
function __awaiter(thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
}
|
||||
|
||||
const labeledRegex = /^[ \t]*date:(.+?)(?:^[ \t]*title:(.+?))?(?:^[ \t]*content:(.+?))?(?=^[ \t]*date:)/gimsu;
|
||||
const timelineLabeledParser = (source) => {
|
||||
source += "\ndate: ";
|
||||
let sourceMatch;
|
||||
const parsed = [];
|
||||
while ((sourceMatch = labeledRegex.exec(source)) !== null) {
|
||||
parsed.push({
|
||||
time: sourceMatch[1],
|
||||
title: sourceMatch[2],
|
||||
description: sourceMatch[3]
|
||||
});
|
||||
}
|
||||
return parsed;
|
||||
};
|
||||
const timelineParser = (source) => {
|
||||
const sourceSplitted = source.split(/^\s*\+ ?/gm).slice(1);
|
||||
sourceSplitted.push("", "");
|
||||
const parsed = [];
|
||||
const counter = sourceSplitted.length - (sourceSplitted.length % 3);
|
||||
for (let i = 0; i < counter; i += 3) {
|
||||
parsed.push({
|
||||
time: sourceSplitted[i],
|
||||
title: sourceSplitted[i + 1],
|
||||
description: sourceSplitted[i + 2]
|
||||
});
|
||||
}
|
||||
return parsed;
|
||||
};
|
||||
const toExport = [
|
||||
{ tag: "timeline", parser: timelineParser },
|
||||
{ tag: "timeline-labeled", parser: timelineLabeledParser },
|
||||
];
|
||||
|
||||
class TimelineElement {
|
||||
constructor(root, sourcePath) {
|
||||
this.addEvent = (info) => {
|
||||
Object.entries(info).map(([key, val]) => {
|
||||
const element = this.root.createDiv({ cls: key });
|
||||
const text = val;
|
||||
obsidian.MarkdownRenderer.renderMarkdown(text, element, this.sourcePath, null);
|
||||
return [key, element];
|
||||
});
|
||||
};
|
||||
this.getElement = () => this.root;
|
||||
this.root = root.createDiv({ cls: 'timeline' });
|
||||
this.sourcePath = sourcePath;
|
||||
}
|
||||
}
|
||||
|
||||
const classRegex = /(?<=^\s*)\[.+?\]/gs;
|
||||
const toClassArray = (input) => {
|
||||
input = input.trim();
|
||||
if (input[0] != "[" || input[input.length - 1] != "]")
|
||||
return [];
|
||||
return input
|
||||
.substring(1, input.length - 1)
|
||||
.trim()
|
||||
.split(/\s*,\s*/);
|
||||
};
|
||||
class TimelinePlugin extends obsidian.Plugin {
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.onload = () => __awaiter(this, void 0, void 0, function* () {
|
||||
toExport.forEach(({ tag, parser }) => {
|
||||
this.registerMarkdownCodeBlockProcessor(tag, (source, root, ctx) => {
|
||||
const timelineElement = new TimelineElement(root, ctx.sourcePath);
|
||||
const el = timelineElement.getElement();
|
||||
el.addClass("timeline");
|
||||
const classMatch = source.match(classRegex);
|
||||
if (classMatch !== null) {
|
||||
const classes = toClassArray(classMatch[0]);
|
||||
el.addClasses(classes);
|
||||
}
|
||||
const events = parser(source);
|
||||
events.forEach(e => timelineElement.addEvent(e));
|
||||
});
|
||||
});
|
||||
console.log("timeline load");
|
||||
});
|
||||
this.onunload = () => __awaiter(this, void 0, void 0, function* () {
|
||||
console.log("timeline onunload");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = TimelinePlugin;
|
||||
|
||||
|
||||
/* nosourcemap */
|
||||
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"id": "obsidian-timeline",
|
||||
"name": "Timeline",
|
||||
"version": "1.1.0",
|
||||
"minAppVersion": "0.15.6",
|
||||
"description": "Used to build great timelines",
|
||||
"author": "George Butco",
|
||||
"authorUrl": "",
|
||||
"isDesktopOnly": false
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
.timeline.line-2 .time::before,.timeline.line-2 .time::after{right:-2.2rem;top:50%;transform:translateY(-50%);border-radius:50%}.timeline.line-2 .time::before{height:1.2rem;width:1.2rem}.timeline.line-2 .time::after{background:rgba(0,0,0,0);border:.2rem solid var(--text-normal);height:.8rem;width:.8rem;opacity:.15}.timeline.line-2::before{width:.2rem;opacity:.15}.timeline.line-3 .time::before{background:var(--timeline-active-color);height:1rem;width:1rem;border:.3rem solid var(--background-primary);right:-2.45rem;top:50%;transform:translateY(-50%);border-radius:50%}.timeline.line-3 .time::after{background:rgba(0,0,0,0)}.timeline.line-3::before{width:.3rem;opacity:.15}.timeline.line-4 .time::before,.timeline.line-4 .time::after{top:50%;transform:translateY(-50%);border-radius:50%}.timeline.line-4 .time::before{background:var(--text-normal);height:1.3rem;width:1.3rem;right:-2.225rem}.timeline.line-4 .time::after{opacity:1;background:var(--timeline-active-color);height:.85rem;width:.85rem;right:-2rem}.timeline.line-4::before{opacity:1;width:.15rem;background-color:rgba(0,0,0,0);background-image:linear-gradient(var(--text-normal) 60%, rgba(255, 255, 255, 0) 0%);background-position:right;background-size:.15rem 1.5rem;background-repeat:repeat-y}.timeline.line-5 .time::before,.timeline.line-5 .time::after{top:50%}.timeline.line-5 .time::before{width:3rem;height:3rem;right:-3.1rem;transform:translateY(-50%)}.timeline.line-5 .time::after{width:1rem;height:1rem;right:0;transform:translateY(-50%) translateX(2.1rem) rotate(45deg)}.timeline.line-5::before{width:.2rem;opacity:.25}.timeline.spaced-lines>.description p{line-height:1.7rem}.timeline.hide-titles>.title{display:none}.timeline{--timeline-active-color: var(--background-modifier-success)}.timeline.active-color-background-modifier-success{--timeline-active-color: var(--background-modifier-success)}.timeline.active-color-background-modifier-error{--timeline-active-color: var(--background-modifier-error)}.timeline.active-color-background-modifier-error-hover{--timeline-active-color: var(--background-modifier-error-hover)}.timeline.active-color-text-accent{--timeline-active-color: var(--text-accent)}.timeline.active-color-text-accent-hover{--timeline-active-color: var(--text-accent-hover)}.timeline.active-color-text-error{--timeline-active-color: var(--text-error)}.timeline.active-color-text-error-hover{--timeline-active-color: var(--text-error-hover)}.timeline.active-color-text-selection{--timeline-active-color: var(--text-selection)}.timeline.active-color-interactive-accent{--timeline-active-color: var(--interactive-accent)}.timeline.active-color-interactive-accent-hover{--timeline-active-color: var(--interactive-accent-hover)}.timeline.active-color-interactive-success{--timeline-active-color: var(--interactive-success)}.timeline{display:grid;grid-template-columns:auto auto 1fr;column-gap:1.5rem;margin:2.3rem 0}.timeline .time>*:first-child,.timeline .title>*:first-child,.timeline .description>*:first-child{margin-top:0}.timeline .time>*:last-child,.timeline .title>*:last-child,.timeline .description>*:last-child{margin-bottom:0}.timeline .description,.timeline .title{grid-column:3}.timeline .time,.timeline .title{display:flex;flex-direction:column;justify-content:center;padding:.4em 0}.timeline .time>*,.timeline .title>*{font-size:1.3em;font-weight:bold}.timeline .time{grid-column:1;position:relative;justify-self:right;text-align:right}.timeline .time::before,.timeline .time::after{content:" ";position:absolute;height:100%;width:.5rem;right:-2rem;top:0}.timeline .time::before{background-color:var(--background-primary)}.timeline .time::after{background-color:var(--text-normal);opacity:.25}.timeline .description{position:relative;margin-bottom:4.5rem;padding-top:.4em}.timeline .description::after{content:" ";position:absolute;border-bottom:.1rem dashed var(--text-normal);opacity:.1;width:100%;height:2.25rem}.timeline .description:last-child{margin-bottom:.4em}.timeline .description:last-child::after{display:none}.timeline::before{content:"";height:100%;width:.5rem;grid-column:2/span 1;grid-row-start:1;grid-row-end:span 1000;background-color:var(--text-normal);opacity:.1}.timeline.body-2>.title,.timeline.body-2>.description,.timeline.body-3>.title,.timeline.body-3>.description,.timeline.body-4>.title,.timeline.body-4>.description{background-color:var(--background-primary-alt)}.timeline.body-2 .description::after,.timeline.body-3 .description::after,.timeline.body-4 .description::after{display:none}.timeline.body-2 .description,.timeline.body-2 .title,.timeline.body-4 .description,.timeline.body-4 .title{padding:1.5rem;padding-top:.4em}.timeline.body-2 .title,.timeline.body-4 .title{padding-bottom:0}.timeline.body-2 .time,.timeline.body-4 .time{margin-top:.4em}.timeline.body-2 .title{border-radius:1.5rem 1.5rem 0 0}.timeline.body-2 .description{border-radius:0 0 1.5rem 1.5rem}.timeline.body-3 .title,.timeline.body-3 .description{margin-left:1rem}.timeline.body-3 .titLine truncated
|
||||
Reference in new issue
Block a user