@real1ty-obsidian-plugins/utils 2.23.0 → 2.25.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/index.js +1 -0
- package/dist/components/index.js.map +1 -1
- package/dist/components/whats-new-modal.d.ts +63 -0
- package/dist/components/whats-new-modal.d.ts.map +1 -0
- package/dist/components/whats-new-modal.js +131 -0
- package/dist/components/whats-new-modal.js.map +1 -0
- package/dist/file/frontmatter-propagation.d.ts +0 -8
- package/dist/file/frontmatter-propagation.d.ts.map +1 -1
- package/dist/file/frontmatter-propagation.js +0 -14
- package/dist/file/frontmatter-propagation.js.map +1 -1
- package/dist/string/changelog-parser.d.ts +17 -0
- package/dist/string/changelog-parser.d.ts.map +1 -0
- package/dist/string/changelog-parser.js +77 -0
- package/dist/string/changelog-parser.js.map +1 -0
- package/dist/string/index.d.ts +1 -0
- package/dist/string/index.d.ts.map +1 -1
- package/dist/string/index.js +1 -0
- package/dist/string/index.js.map +1 -1
- package/package.json +1 -1
- package/src/components/index.ts +1 -0
- package/src/components/whats-new-modal.ts +203 -0
- package/src/file/frontmatter-propagation.ts +0 -25
- package/src/string/changelog-parser.ts +100 -0
- package/src/string/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC"}
|
package/dist/components/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC","sourcesContent":["export * from \"./frontmatter-propagation-modal\";\nexport * from \"./input-managers\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,iCAAiC,CAAC;AAChD,cAAc,kBAAkB,CAAC;AACjC,cAAc,mBAAmB,CAAC","sourcesContent":["export * from \"./frontmatter-propagation-modal\";\nexport * from \"./input-managers\";\nexport * from \"./whats-new-modal\";\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { App, Plugin } from "obsidian";
|
|
2
|
+
import { Modal } from "obsidian";
|
|
3
|
+
export interface WhatsNewModalConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The CSS class prefix/suffix to use for styling.
|
|
6
|
+
* Example: "custom-calendar" will generate classes like "custom-calendar-whats-new-modal"
|
|
7
|
+
*/
|
|
8
|
+
cssPrefix: string;
|
|
9
|
+
/**
|
|
10
|
+
* Display name of the plugin.
|
|
11
|
+
* Example: "Custom Calendar"
|
|
12
|
+
*/
|
|
13
|
+
pluginName: string;
|
|
14
|
+
/**
|
|
15
|
+
* Raw changelog markdown content to parse.
|
|
16
|
+
*/
|
|
17
|
+
changelogContent: string;
|
|
18
|
+
/**
|
|
19
|
+
* Links to external resources.
|
|
20
|
+
*/
|
|
21
|
+
links: {
|
|
22
|
+
/**
|
|
23
|
+
* URL to support/donate page.
|
|
24
|
+
*/
|
|
25
|
+
support?: string;
|
|
26
|
+
/**
|
|
27
|
+
* URL to full changelog page.
|
|
28
|
+
*/
|
|
29
|
+
changelog?: string;
|
|
30
|
+
/**
|
|
31
|
+
* URL to documentation.
|
|
32
|
+
*/
|
|
33
|
+
documentation?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generic "What's New" modal that displays changelog entries between versions.
|
|
38
|
+
* Supports custom CSS prefixes, plugin names, and configurable links.
|
|
39
|
+
*/
|
|
40
|
+
export declare class WhatsNewModal extends Modal {
|
|
41
|
+
private plugin;
|
|
42
|
+
private config;
|
|
43
|
+
private fromVersion;
|
|
44
|
+
private toVersion;
|
|
45
|
+
constructor(app: App, plugin: Plugin, config: WhatsNewModalConfig, fromVersion: string, toVersion: string);
|
|
46
|
+
/**
|
|
47
|
+
* Helper to create CSS class names with the configured prefix.
|
|
48
|
+
*/
|
|
49
|
+
private cls;
|
|
50
|
+
/**
|
|
51
|
+
* Helper to add CSS class to an element.
|
|
52
|
+
*/
|
|
53
|
+
private addCls;
|
|
54
|
+
/**
|
|
55
|
+
* Makes external links in rendered markdown clickable by adding click handlers.
|
|
56
|
+
* Finds all anchor tags with external URLs (http/https) and adds click events
|
|
57
|
+
* that open the links in the user's default browser.
|
|
58
|
+
*/
|
|
59
|
+
private makeExternalLinksClickable;
|
|
60
|
+
onOpen(): Promise<void>;
|
|
61
|
+
onClose(): void;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=whats-new-modal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whats-new-modal.d.ts","sourceRoot":"","sources":["../../src/components/whats-new-modal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAoB,KAAK,EAAE,MAAM,UAAU,CAAC;AAGnD,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,SAAS,EAAE,MAAM,CAAC;IAElB;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IAEnB;;OAEG;IACH,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;OAEG;IACH,KAAK,EAAE;QACN;;WAEG;QACH,OAAO,CAAC,EAAE,MAAM,CAAC;QAEjB;;WAEG;QACH,SAAS,CAAC,EAAE,MAAM,CAAC;QAEnB;;WAEG;QACH,aAAa,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACF;AAED;;;GAGG;AACH,qBAAa,aAAc,SAAQ,KAAK;IAGtC,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,SAAS;gBAJjB,GAAG,EAAE,GAAG,EACA,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,mBAAmB,EAC3B,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM;IAK1B;;OAEG;IACH,OAAO,CAAC,GAAG;IAIX;;OAEG;IACH,OAAO,CAAC,MAAM;IAId;;;;OAIG;IACH,OAAO,CAAC,0BAA0B;IAoB5B,MAAM;IAsGZ,OAAO;CAGP"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { __awaiter } from "tslib";
|
|
2
|
+
import { MarkdownRenderer, Modal } from "obsidian";
|
|
3
|
+
import { formatChangelogSections, getChangelogSince } from "../string/changelog-parser";
|
|
4
|
+
/**
|
|
5
|
+
* Generic "What's New" modal that displays changelog entries between versions.
|
|
6
|
+
* Supports custom CSS prefixes, plugin names, and configurable links.
|
|
7
|
+
*/
|
|
8
|
+
export class WhatsNewModal extends Modal {
|
|
9
|
+
constructor(app, plugin, config, fromVersion, toVersion) {
|
|
10
|
+
super(app);
|
|
11
|
+
this.plugin = plugin;
|
|
12
|
+
this.config = config;
|
|
13
|
+
this.fromVersion = fromVersion;
|
|
14
|
+
this.toVersion = toVersion;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Helper to create CSS class names with the configured prefix.
|
|
18
|
+
*/
|
|
19
|
+
cls(suffix) {
|
|
20
|
+
return `${this.config.cssPrefix}-${suffix}`;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Helper to add CSS class to an element.
|
|
24
|
+
*/
|
|
25
|
+
addCls(el, suffix) {
|
|
26
|
+
el.classList.add(this.cls(suffix));
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Makes external links in rendered markdown clickable by adding click handlers.
|
|
30
|
+
* Finds all anchor tags with external URLs (http/https) and adds click events
|
|
31
|
+
* that open the links in the user's default browser.
|
|
32
|
+
*/
|
|
33
|
+
makeExternalLinksClickable(container) {
|
|
34
|
+
const links = container.querySelectorAll("a[href]");
|
|
35
|
+
// Convert NodeList to Array for iteration
|
|
36
|
+
Array.from(links).forEach((link) => {
|
|
37
|
+
const href = link.getAttribute("href");
|
|
38
|
+
// Only handle external HTTP(S) links
|
|
39
|
+
if (href && (href.startsWith("http://") || href.startsWith("https://"))) {
|
|
40
|
+
link.addEventListener("click", (event) => {
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
window.open(href, "_blank");
|
|
43
|
+
});
|
|
44
|
+
// Add visual indicator that it's an external link
|
|
45
|
+
link.addClass("external-link");
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
onOpen() {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
const { contentEl } = this;
|
|
52
|
+
contentEl.empty();
|
|
53
|
+
this.addCls(contentEl, "whats-new-modal");
|
|
54
|
+
// Header section
|
|
55
|
+
const header = contentEl.createDiv({ cls: this.cls("whats-new-header") });
|
|
56
|
+
header.createEl("h2", {
|
|
57
|
+
text: `${this.config.pluginName} updated to v${this.toVersion}`,
|
|
58
|
+
});
|
|
59
|
+
header.createEl("p", {
|
|
60
|
+
text: `Changes since v${this.fromVersion}`,
|
|
61
|
+
cls: this.cls("whats-new-subtitle"),
|
|
62
|
+
});
|
|
63
|
+
// Support section (optional)
|
|
64
|
+
if (this.config.links.support) {
|
|
65
|
+
const supportSection = contentEl.createDiv({
|
|
66
|
+
cls: this.cls("whats-new-support"),
|
|
67
|
+
});
|
|
68
|
+
supportSection.createEl("h3", { text: "Support My Work" });
|
|
69
|
+
const supportText = supportSection.createEl("p");
|
|
70
|
+
supportText.createSpan({ text: "If you enjoy using this plugin, please consider " });
|
|
71
|
+
supportText.createEl("a", {
|
|
72
|
+
text: "supporting my work",
|
|
73
|
+
href: this.config.links.support,
|
|
74
|
+
});
|
|
75
|
+
supportText.createSpan({
|
|
76
|
+
text: ". Your support helps keep this plugin maintained and improved!",
|
|
77
|
+
});
|
|
78
|
+
contentEl.createEl("hr");
|
|
79
|
+
}
|
|
80
|
+
// Changelog content
|
|
81
|
+
const changelogSections = getChangelogSince(this.config.changelogContent, this.fromVersion, this.toVersion);
|
|
82
|
+
if (changelogSections.length === 0) {
|
|
83
|
+
contentEl.createEl("p", {
|
|
84
|
+
text: "No significant changes found in this update.",
|
|
85
|
+
cls: this.cls("whats-new-empty"),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const changelogContainer = contentEl.createDiv({
|
|
90
|
+
cls: this.cls("whats-new-content"),
|
|
91
|
+
});
|
|
92
|
+
const markdownContent = formatChangelogSections(changelogSections);
|
|
93
|
+
yield MarkdownRenderer.render(this.app, markdownContent, changelogContainer, "/", this.plugin);
|
|
94
|
+
// Make external links clickable
|
|
95
|
+
this.makeExternalLinksClickable(changelogContainer);
|
|
96
|
+
}
|
|
97
|
+
// Action buttons
|
|
98
|
+
const buttonContainer = contentEl.createDiv({
|
|
99
|
+
cls: this.cls("whats-new-buttons"),
|
|
100
|
+
});
|
|
101
|
+
// Full changelog button (optional)
|
|
102
|
+
if (this.config.links.changelog) {
|
|
103
|
+
const changelogBtn = buttonContainer.createEl("button", {
|
|
104
|
+
text: "Full Changelog",
|
|
105
|
+
});
|
|
106
|
+
changelogBtn.addEventListener("click", () => {
|
|
107
|
+
window.open(this.config.links.changelog, "_blank");
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
// Documentation button (optional)
|
|
111
|
+
if (this.config.links.documentation) {
|
|
112
|
+
const docsBtn = buttonContainer.createEl("button", {
|
|
113
|
+
text: "Documentation",
|
|
114
|
+
});
|
|
115
|
+
docsBtn.addEventListener("click", () => {
|
|
116
|
+
window.open(this.config.links.documentation, "_blank");
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
// Close button (always present)
|
|
120
|
+
const closeBtn = buttonContainer.createEl("button", {
|
|
121
|
+
text: "Close",
|
|
122
|
+
cls: this.cls("mod-cta"),
|
|
123
|
+
});
|
|
124
|
+
closeBtn.addEventListener("click", () => this.close());
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
onClose() {
|
|
128
|
+
this.contentEl.empty();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=whats-new-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"whats-new-modal.js","sourceRoot":"","sources":["../../src/components/whats-new-modal.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AACnD,OAAO,EAAE,uBAAuB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAyCxF;;;GAGG;AACH,MAAM,OAAO,aAAc,SAAQ,KAAK;IACvC,YACC,GAAQ,EACA,MAAc,EACd,MAA2B,EAC3B,WAAmB,EACnB,SAAiB;QAEzB,KAAK,CAAC,GAAG,CAAC,CAAC;QALH,WAAM,GAAN,MAAM,CAAQ;QACd,WAAM,GAAN,MAAM,CAAqB;QAC3B,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAAQ;IAG1B,CAAC;IAED;;OAEG;IACK,GAAG,CAAC,MAAc;QACzB,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,MAAM,EAAE,CAAC;IAC7C,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,EAAe,EAAE,MAAc;QAC7C,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;IACpC,CAAC;IAED;;;;OAIG;IACK,0BAA0B,CAAC,SAAsB;QACxD,MAAM,KAAK,GAAG,SAAS,CAAC,gBAAgB,CAAoB,SAAS,CAAC,CAAC;QAEv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AG,eAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE;gBACnD,IAAI,EAAE,OAAO;gBACb,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,CAAC;aACxB,CAAC,CAAC;YACH,QAAQ,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC;QACxD,CAAC;KAAA;IAED,OAAO;QACN,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;IACxB,CAAC;CACD","sourcesContent":["import type { App, Plugin } from \"obsidian\";\nimport { MarkdownRenderer, Modal } from \"obsidian\";\nimport { formatChangelogSections, getChangelogSince } from \"../string/changelog-parser\";\n\nexport interface WhatsNewModalConfig {\n\t/**\n\t * The CSS class prefix/suffix to use for styling.\n\t * Example: \"custom-calendar\" will generate classes like \"custom-calendar-whats-new-modal\"\n\t */\n\tcssPrefix: string;\n\n\t/**\n\t * Display name of the plugin.\n\t * Example: \"Custom Calendar\"\n\t */\n\tpluginName: string;\n\n\t/**\n\t * Raw changelog markdown content to parse.\n\t */\n\tchangelogContent: string;\n\n\t/**\n\t * Links to external resources.\n\t */\n\tlinks: {\n\t\t/**\n\t\t * URL to support/donate page.\n\t\t */\n\t\tsupport?: string;\n\n\t\t/**\n\t\t * URL to full changelog page.\n\t\t */\n\t\tchangelog?: string;\n\n\t\t/**\n\t\t * URL to documentation.\n\t\t */\n\t\tdocumentation?: string;\n\t};\n}\n\n/**\n * Generic \"What's New\" modal that displays changelog entries between versions.\n * Supports custom CSS prefixes, plugin names, and configurable links.\n */\nexport class WhatsNewModal extends Modal {\n\tconstructor(\n\t\tapp: App,\n\t\tprivate plugin: Plugin,\n\t\tprivate config: WhatsNewModalConfig,\n\t\tprivate fromVersion: string,\n\t\tprivate toVersion: string\n\t) {\n\t\tsuper(app);\n\t}\n\n\t/**\n\t * Helper to create CSS class names with the configured prefix.\n\t */\n\tprivate cls(suffix: string): string {\n\t\treturn `${this.config.cssPrefix}-${suffix}`;\n\t}\n\n\t/**\n\t * Helper to add CSS class to an element.\n\t */\n\tprivate addCls(el: HTMLElement, suffix: string): void {\n\t\tel.classList.add(this.cls(suffix));\n\t}\n\n\t/**\n\t * Makes external links in rendered markdown clickable by adding click handlers.\n\t * Finds all anchor tags with external URLs (http/https) and adds click events\n\t * that open the links in the user's default browser.\n\t */\n\tprivate makeExternalLinksClickable(container: HTMLElement): void {\n\t\tconst links = container.querySelectorAll<HTMLAnchorElement>(\"a[href]\");\n\n\t\t// Convert NodeList to Array for iteration\n\t\tArray.from(links).forEach((link) => {\n\t\t\tconst href = link.getAttribute(\"href\");\n\n\t\t\t// Only handle external HTTP(S) links\n\t\t\tif (href && (href.startsWith(\"http://\") || href.startsWith(\"https://\"))) {\n\t\t\t\tlink.addEventListener(\"click\", (event: MouseEvent) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\twindow.open(href, \"_blank\");\n\t\t\t\t});\n\n\t\t\t\t// Add visual indicator that it's an external link\n\t\t\t\tlink.addClass(\"external-link\");\n\t\t\t}\n\t\t});\n\t}\n\n\tasync onOpen() {\n\t\tconst { contentEl } = this;\n\t\tcontentEl.empty();\n\n\t\tthis.addCls(contentEl, \"whats-new-modal\");\n\n\t\t// Header section\n\t\tconst header = contentEl.createDiv({ cls: this.cls(\"whats-new-header\") });\n\t\theader.createEl(\"h2\", {\n\t\t\ttext: `${this.config.pluginName} updated to v${this.toVersion}`,\n\t\t});\n\n\t\theader.createEl(\"p\", {\n\t\t\ttext: `Changes since v${this.fromVersion}`,\n\t\t\tcls: this.cls(\"whats-new-subtitle\"),\n\t\t});\n\n\t\t// Support section (optional)\n\t\tif (this.config.links.support) {\n\t\t\tconst supportSection = contentEl.createDiv({\n\t\t\t\tcls: this.cls(\"whats-new-support\"),\n\t\t\t});\n\n\t\t\tsupportSection.createEl(\"h3\", { text: \"Support My Work\" });\n\n\t\t\tconst supportText = supportSection.createEl(\"p\");\n\t\t\tsupportText.createSpan({ text: \"If you enjoy using this plugin, please consider \" });\n\t\t\tsupportText.createEl(\"a\", {\n\t\t\t\ttext: \"supporting my work\",\n\t\t\t\thref: this.config.links.support,\n\t\t\t});\n\t\t\tsupportText.createSpan({\n\t\t\t\ttext: \". Your support helps keep this plugin maintained and improved!\",\n\t\t\t});\n\n\t\t\tcontentEl.createEl(\"hr\");\n\t\t}\n\n\t\t// Changelog content\n\t\tconst changelogSections = getChangelogSince(\n\t\t\tthis.config.changelogContent,\n\t\t\tthis.fromVersion,\n\t\t\tthis.toVersion\n\t\t);\n\n\t\tif (changelogSections.length === 0) {\n\t\t\tcontentEl.createEl(\"p\", {\n\t\t\t\ttext: \"No significant changes found in this update.\",\n\t\t\t\tcls: this.cls(\"whats-new-empty\"),\n\t\t\t});\n\t\t} else {\n\t\t\tconst changelogContainer = contentEl.createDiv({\n\t\t\t\tcls: this.cls(\"whats-new-content\"),\n\t\t\t});\n\n\t\t\tconst markdownContent = formatChangelogSections(changelogSections);\n\n\t\t\tawait MarkdownRenderer.render(\n\t\t\t\tthis.app,\n\t\t\t\tmarkdownContent,\n\t\t\t\tchangelogContainer,\n\t\t\t\t\"/\",\n\t\t\t\tthis.plugin\n\t\t\t);\n\n\t\t\t// Make external links clickable\n\t\t\tthis.makeExternalLinksClickable(changelogContainer);\n\t\t}\n\n\t\t// Action buttons\n\t\tconst buttonContainer = contentEl.createDiv({\n\t\t\tcls: this.cls(\"whats-new-buttons\"),\n\t\t});\n\n\t\t// Full changelog button (optional)\n\t\tif (this.config.links.changelog) {\n\t\t\tconst changelogBtn = buttonContainer.createEl(\"button\", {\n\t\t\t\ttext: \"Full Changelog\",\n\t\t\t});\n\t\t\tchangelogBtn.addEventListener(\"click\", () => {\n\t\t\t\twindow.open(this.config.links.changelog, \"_blank\");\n\t\t\t});\n\t\t}\n\n\t\t// Documentation button (optional)\n\t\tif (this.config.links.documentation) {\n\t\t\tconst docsBtn = buttonContainer.createEl(\"button\", {\n\t\t\t\ttext: \"Documentation\",\n\t\t\t});\n\t\t\tdocsBtn.addEventListener(\"click\", () => {\n\t\t\t\twindow.open(this.config.links.documentation, \"_blank\");\n\t\t\t});\n\t\t}\n\n\t\t// Close button (always present)\n\t\tconst closeBtn = buttonContainer.createEl(\"button\", {\n\t\t\ttext: \"Close\",\n\t\t\tcls: this.cls(\"mod-cta\"),\n\t\t});\n\t\tcloseBtn.addEventListener(\"click\", () => this.close());\n\t}\n\n\tonClose() {\n\t\tthis.contentEl.empty();\n\t}\n}\n"]}
|
|
@@ -1,12 +1,4 @@
|
|
|
1
1
|
import type { App } from "obsidian";
|
|
2
2
|
import type { Frontmatter, FrontmatterDiff } from "./frontmatter-diff";
|
|
3
|
-
export interface NexusPropertiesSettings {
|
|
4
|
-
excludedPropagatedProps?: string;
|
|
5
|
-
parentProp: string;
|
|
6
|
-
childrenProp: string;
|
|
7
|
-
relatedProp: string;
|
|
8
|
-
zettelIdProp: string;
|
|
9
|
-
}
|
|
10
|
-
export declare function parseExcludedProps(settings: NexusPropertiesSettings): Set<string>;
|
|
11
3
|
export declare function applyFrontmatterChanges(app: App, targetPath: string, sourceFrontmatter: Frontmatter, diff: FrontmatterDiff): Promise<void>;
|
|
12
4
|
//# sourceMappingURL=frontmatter-propagation.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter-propagation.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEvE,
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation.d.ts","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAEpC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAEvE,wBAAsB,uBAAuB,CAC5C,GAAG,EAAE,GAAG,EACR,UAAU,EAAE,MAAM,EAClB,iBAAiB,EAAE,WAAW,EAC9B,IAAI,EAAE,eAAe,GACnB,OAAO,CAAC,IAAI,CAAC,CAwBf"}
|
|
@@ -1,19 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from "tslib";
|
|
2
2
|
import { TFile } from "obsidian";
|
|
3
|
-
export function parseExcludedProps(settings) {
|
|
4
|
-
const excludedPropsStr = settings.excludedPropagatedProps || "";
|
|
5
|
-
const userExcluded = excludedPropsStr
|
|
6
|
-
.split(",")
|
|
7
|
-
.map((prop) => prop.trim())
|
|
8
|
-
.filter((prop) => prop.length > 0);
|
|
9
|
-
const alwaysExcluded = [
|
|
10
|
-
settings.parentProp,
|
|
11
|
-
settings.childrenProp,
|
|
12
|
-
settings.relatedProp,
|
|
13
|
-
settings.zettelIdProp,
|
|
14
|
-
];
|
|
15
|
-
return new Set([...alwaysExcluded, ...userExcluded]);
|
|
16
|
-
}
|
|
17
3
|
export function applyFrontmatterChanges(app, targetPath, sourceFrontmatter, diff) {
|
|
18
4
|
return __awaiter(this, void 0, void 0, function* () {
|
|
19
5
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frontmatter-propagation.js","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"frontmatter-propagation.js","sourceRoot":"","sources":["../../src/file/frontmatter-propagation.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAGjC,MAAM,UAAgB,uBAAuB,CAC5C,GAAQ,EACR,UAAkB,EAClB,iBAA8B,EAC9B,IAAqB;;QAErB,IAAI,CAAC;YACJ,MAAM,IAAI,GAAG,GAAG,CAAC,KAAK,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;YACzD,IAAI,CAAC,CAAC,IAAI,YAAY,KAAK,CAAC,EAAE,CAAC;gBAC9B,OAAO,CAAC,IAAI,CAAC,0BAA0B,UAAU,EAAE,CAAC,CAAC;gBACrD,OAAO;YACR,CAAC;YAED,MAAM,GAAG,CAAC,WAAW,CAAC,kBAAkB,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE,EAAE;gBACrD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,KAAK,EAAE,CAAC;oBACjC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChD,CAAC;gBAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;oBACpC,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAChD,CAAC;gBAED,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;oBACnC,OAAO,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBACvB,CAAC;YACF,CAAC,CAAC,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,OAAO,CAAC,KAAK,CAAC,yCAAyC,UAAU,GAAG,EAAE,KAAK,CAAC,CAAC;QAC9E,CAAC;IACF,CAAC;CAAA","sourcesContent":["import type { App } from \"obsidian\";\nimport { TFile } from \"obsidian\";\nimport type { Frontmatter, FrontmatterDiff } from \"./frontmatter-diff\";\n\nexport async function applyFrontmatterChanges(\n\tapp: App,\n\ttargetPath: string,\n\tsourceFrontmatter: Frontmatter,\n\tdiff: FrontmatterDiff\n): Promise<void> {\n\ttry {\n\t\tconst file = app.vault.getAbstractFileByPath(targetPath);\n\t\tif (!(file instanceof TFile)) {\n\t\t\tconsole.warn(`Target file not found: ${targetPath}`);\n\t\t\treturn;\n\t\t}\n\n\t\tawait app.fileManager.processFrontMatter(file, (fm) => {\n\t\t\tfor (const change of diff.added) {\n\t\t\t\tfm[change.key] = sourceFrontmatter[change.key];\n\t\t\t}\n\n\t\t\tfor (const change of diff.modified) {\n\t\t\t\tfm[change.key] = sourceFrontmatter[change.key];\n\t\t\t}\n\n\t\t\tfor (const change of diff.deleted) {\n\t\t\t\tdelete fm[change.key];\n\t\t\t}\n\t\t});\n\t} catch (error) {\n\t\tconsole.error(`Error applying frontmatter changes to ${targetPath}:`, error);\n\t}\n}\n"]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
interface VersionSection {
|
|
2
|
+
version: string;
|
|
3
|
+
content: string;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Parses changelog markdown content into version sections.
|
|
7
|
+
* Each section starts with "## X.Y.Z" heading.
|
|
8
|
+
*/
|
|
9
|
+
export declare function parseChangelog(changelogContent: string): VersionSection[];
|
|
10
|
+
/**
|
|
11
|
+
* Gets all changelog sections between fromVersion (exclusive) and toVersion (inclusive).
|
|
12
|
+
* Sections are returned in reverse chronological order (newest first).
|
|
13
|
+
*/
|
|
14
|
+
export declare function getChangelogSince(changelogContent: string, fromVersion: string, toVersion: string): VersionSection[];
|
|
15
|
+
export declare function formatChangelogSections(sections: VersionSection[]): string;
|
|
16
|
+
export type { VersionSection };
|
|
17
|
+
//# sourceMappingURL=changelog-parser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changelog-parser.d.ts","sourceRoot":"","sources":["../../src/string/changelog-parser.ts"],"names":[],"mappings":"AAAA,UAAU,cAAc;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,gBAAgB,EAAE,MAAM,GAAG,cAAc,EAAE,CAiCzE;AAyBD;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,gBAAgB,EAAE,MAAM,EACxB,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GACf,cAAc,EAAE,CAQlB;AAED,wBAAgB,uBAAuB,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,MAAM,CAY1E;AAED,YAAY,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Parses changelog markdown content into version sections.
|
|
3
|
+
* Each section starts with "## X.Y.Z" heading.
|
|
4
|
+
*/
|
|
5
|
+
export function parseChangelog(changelogContent) {
|
|
6
|
+
const sections = [];
|
|
7
|
+
const lines = changelogContent.split("\n");
|
|
8
|
+
let currentVersion = null;
|
|
9
|
+
let currentContent = [];
|
|
10
|
+
for (const line of lines) {
|
|
11
|
+
const versionMatch = line.match(/^##\s+(\d+\.\d+\.\d+)/);
|
|
12
|
+
if (versionMatch) {
|
|
13
|
+
if (currentVersion !== null) {
|
|
14
|
+
sections.push({
|
|
15
|
+
version: currentVersion,
|
|
16
|
+
content: currentContent.join("\n").trim(),
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
currentVersion = versionMatch[1];
|
|
20
|
+
currentContent = [];
|
|
21
|
+
}
|
|
22
|
+
else if (currentVersion !== null) {
|
|
23
|
+
currentContent.push(line);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
if (currentVersion !== null && currentContent.length > 0) {
|
|
27
|
+
sections.push({
|
|
28
|
+
version: currentVersion,
|
|
29
|
+
content: currentContent.join("\n").trim(),
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
return sections;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Compares two semantic version strings.
|
|
36
|
+
* Returns:
|
|
37
|
+
* - negative if v1 < v2
|
|
38
|
+
* - 0 if v1 === v2
|
|
39
|
+
* - positive if v1 > v2
|
|
40
|
+
*/
|
|
41
|
+
function compareVersions(v1, v2) {
|
|
42
|
+
const parts1 = v1.split(".").map(Number);
|
|
43
|
+
const parts2 = v2.split(".").map(Number);
|
|
44
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
45
|
+
const num1 = parts1[i] || 0;
|
|
46
|
+
const num2 = parts2[i] || 0;
|
|
47
|
+
if (num1 !== num2) {
|
|
48
|
+
return num1 - num2;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return 0;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Gets all changelog sections between fromVersion (exclusive) and toVersion (inclusive).
|
|
55
|
+
* Sections are returned in reverse chronological order (newest first).
|
|
56
|
+
*/
|
|
57
|
+
export function getChangelogSince(changelogContent, fromVersion, toVersion) {
|
|
58
|
+
const allSections = parseChangelog(changelogContent);
|
|
59
|
+
return allSections.filter((section) => {
|
|
60
|
+
const isAfterFrom = compareVersions(section.version, fromVersion) > 0;
|
|
61
|
+
const isBeforeOrEqualTo = compareVersions(section.version, toVersion) <= 0;
|
|
62
|
+
return isAfterFrom && isBeforeOrEqualTo;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
export function formatChangelogSections(sections) {
|
|
66
|
+
if (sections.length === 0) {
|
|
67
|
+
return "No changes found.";
|
|
68
|
+
}
|
|
69
|
+
return sections
|
|
70
|
+
.map((section) => {
|
|
71
|
+
// Escape Dataview inline queries to prevent parsing errors
|
|
72
|
+
const content = section.content.replace(/`=([^`]+)`/g, "`\\=$1`");
|
|
73
|
+
return `## ${section.version}\n\n${content}`;
|
|
74
|
+
})
|
|
75
|
+
.join("\n\n");
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=changelog-parser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"changelog-parser.js","sourceRoot":"","sources":["../../src/string/changelog-parser.ts"],"names":[],"mappings":"AAKA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,gBAAwB;IACtD,MAAM,QAAQ,GAAqB,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAE3C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":["interface VersionSection {\n\tversion: string;\n\tcontent: string;\n}\n\n/**\n * Parses changelog markdown content into version sections.\n * Each section starts with \"## X.Y.Z\" heading.\n */\nexport function parseChangelog(changelogContent: string): VersionSection[] {\n\tconst sections: VersionSection[] = [];\n\tconst lines = changelogContent.split(\"\\n\");\n\n\tlet currentVersion: string | null = null;\n\tlet currentContent: string[] = [];\n\n\tfor (const line of lines) {\n\t\tconst versionMatch = line.match(/^##\\s+(\\d+\\.\\d+\\.\\d+)/);\n\n\t\tif (versionMatch) {\n\t\t\tif (currentVersion !== null) {\n\t\t\t\tsections.push({\n\t\t\t\t\tversion: currentVersion,\n\t\t\t\t\tcontent: currentContent.join(\"\\n\").trim(),\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tcurrentVersion = versionMatch[1];\n\t\t\tcurrentContent = [];\n\t\t} else if (currentVersion !== null) {\n\t\t\tcurrentContent.push(line);\n\t\t}\n\t}\n\n\tif (currentVersion !== null && currentContent.length > 0) {\n\t\tsections.push({\n\t\t\tversion: currentVersion,\n\t\t\tcontent: currentContent.join(\"\\n\").trim(),\n\t\t});\n\t}\n\n\treturn sections;\n}\n\n/**\n * Compares two semantic version strings.\n * Returns:\n * - negative if v1 < v2\n * - 0 if v1 === v2\n * - positive if v1 > v2\n */\nfunction compareVersions(v1: string, v2: string): number {\n\tconst parts1 = v1.split(\".\").map(Number);\n\tconst parts2 = v2.split(\".\").map(Number);\n\n\tfor (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {\n\t\tconst num1 = parts1[i] || 0;\n\t\tconst num2 = parts2[i] || 0;\n\n\t\tif (num1 !== num2) {\n\t\t\treturn num1 - num2;\n\t\t}\n\t}\n\n\treturn 0;\n}\n\n/**\n * Gets all changelog sections between fromVersion (exclusive) and toVersion (inclusive).\n * Sections are returned in reverse chronological order (newest first).\n */\nexport function getChangelogSince(\n\tchangelogContent: string,\n\tfromVersion: string,\n\ttoVersion: string\n): VersionSection[] {\n\tconst allSections = parseChangelog(changelogContent);\n\n\treturn allSections.filter((section) => {\n\t\tconst isAfterFrom = compareVersions(section.version, fromVersion) > 0;\n\t\tconst isBeforeOrEqualTo = compareVersions(section.version, toVersion) <= 0;\n\t\treturn isAfterFrom && isBeforeOrEqualTo;\n\t});\n}\n\nexport function formatChangelogSections(sections: VersionSection[]): string {\n\tif (sections.length === 0) {\n\t\treturn \"No changes found.\";\n\t}\n\n\treturn sections\n\t\t.map((section) => {\n\t\t\t// Escape Dataview inline queries to prevent parsing errors\n\t\t\tconst content = section.content.replace(/`=([^`]+)`/g, \"`\\\\=$1`\");\n\t\t\treturn `## ${section.version}\\n\\n${content}`;\n\t\t})\n\t\t.join(\"\\n\\n\");\n}\n\nexport type { VersionSection };\n"]}
|
package/dist/string/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC"}
|
package/dist/string/index.js
CHANGED
package/dist/string/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC","sourcesContent":["export * from \"./filename-utils\";\nexport * from \"./string\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/string/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC","sourcesContent":["export * from \"./changelog-parser\";\nexport * from \"./filename-utils\";\nexport * from \"./string\";\n"]}
|
package/package.json
CHANGED
package/src/components/index.ts
CHANGED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import type { App, Plugin } from "obsidian";
|
|
2
|
+
import { MarkdownRenderer, Modal } from "obsidian";
|
|
3
|
+
import { formatChangelogSections, getChangelogSince } from "../string/changelog-parser";
|
|
4
|
+
|
|
5
|
+
export interface WhatsNewModalConfig {
|
|
6
|
+
/**
|
|
7
|
+
* The CSS class prefix/suffix to use for styling.
|
|
8
|
+
* Example: "custom-calendar" will generate classes like "custom-calendar-whats-new-modal"
|
|
9
|
+
*/
|
|
10
|
+
cssPrefix: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Display name of the plugin.
|
|
14
|
+
* Example: "Custom Calendar"
|
|
15
|
+
*/
|
|
16
|
+
pluginName: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Raw changelog markdown content to parse.
|
|
20
|
+
*/
|
|
21
|
+
changelogContent: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Links to external resources.
|
|
25
|
+
*/
|
|
26
|
+
links: {
|
|
27
|
+
/**
|
|
28
|
+
* URL to support/donate page.
|
|
29
|
+
*/
|
|
30
|
+
support?: string;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* URL to full changelog page.
|
|
34
|
+
*/
|
|
35
|
+
changelog?: string;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* URL to documentation.
|
|
39
|
+
*/
|
|
40
|
+
documentation?: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Generic "What's New" modal that displays changelog entries between versions.
|
|
46
|
+
* Supports custom CSS prefixes, plugin names, and configurable links.
|
|
47
|
+
*/
|
|
48
|
+
export class WhatsNewModal extends Modal {
|
|
49
|
+
constructor(
|
|
50
|
+
app: App,
|
|
51
|
+
private plugin: Plugin,
|
|
52
|
+
private config: WhatsNewModalConfig,
|
|
53
|
+
private fromVersion: string,
|
|
54
|
+
private toVersion: string
|
|
55
|
+
) {
|
|
56
|
+
super(app);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Helper to create CSS class names with the configured prefix.
|
|
61
|
+
*/
|
|
62
|
+
private cls(suffix: string): string {
|
|
63
|
+
return `${this.config.cssPrefix}-${suffix}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Helper to add CSS class to an element.
|
|
68
|
+
*/
|
|
69
|
+
private addCls(el: HTMLElement, suffix: string): void {
|
|
70
|
+
el.classList.add(this.cls(suffix));
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Makes external links in rendered markdown clickable by adding click handlers.
|
|
75
|
+
* Finds all anchor tags with external URLs (http/https) and adds click events
|
|
76
|
+
* that open the links in the user's default browser.
|
|
77
|
+
*/
|
|
78
|
+
private makeExternalLinksClickable(container: HTMLElement): void {
|
|
79
|
+
const links = container.querySelectorAll<HTMLAnchorElement>("a[href]");
|
|
80
|
+
|
|
81
|
+
// Convert NodeList to Array for iteration
|
|
82
|
+
Array.from(links).forEach((link) => {
|
|
83
|
+
const href = link.getAttribute("href");
|
|
84
|
+
|
|
85
|
+
// Only handle external HTTP(S) links
|
|
86
|
+
if (href && (href.startsWith("http://") || href.startsWith("https://"))) {
|
|
87
|
+
link.addEventListener("click", (event: MouseEvent) => {
|
|
88
|
+
event.preventDefault();
|
|
89
|
+
window.open(href, "_blank");
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// Add visual indicator that it's an external link
|
|
93
|
+
link.addClass("external-link");
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
async onOpen() {
|
|
99
|
+
const { contentEl } = this;
|
|
100
|
+
contentEl.empty();
|
|
101
|
+
|
|
102
|
+
this.addCls(contentEl, "whats-new-modal");
|
|
103
|
+
|
|
104
|
+
// Header section
|
|
105
|
+
const header = contentEl.createDiv({ cls: this.cls("whats-new-header") });
|
|
106
|
+
header.createEl("h2", {
|
|
107
|
+
text: `${this.config.pluginName} updated to v${this.toVersion}`,
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
header.createEl("p", {
|
|
111
|
+
text: `Changes since v${this.fromVersion}`,
|
|
112
|
+
cls: this.cls("whats-new-subtitle"),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Support section (optional)
|
|
116
|
+
if (this.config.links.support) {
|
|
117
|
+
const supportSection = contentEl.createDiv({
|
|
118
|
+
cls: this.cls("whats-new-support"),
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
supportSection.createEl("h3", { text: "Support My Work" });
|
|
122
|
+
|
|
123
|
+
const supportText = supportSection.createEl("p");
|
|
124
|
+
supportText.createSpan({ text: "If you enjoy using this plugin, please consider " });
|
|
125
|
+
supportText.createEl("a", {
|
|
126
|
+
text: "supporting my work",
|
|
127
|
+
href: this.config.links.support,
|
|
128
|
+
});
|
|
129
|
+
supportText.createSpan({
|
|
130
|
+
text: ". Your support helps keep this plugin maintained and improved!",
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
contentEl.createEl("hr");
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Changelog content
|
|
137
|
+
const changelogSections = getChangelogSince(
|
|
138
|
+
this.config.changelogContent,
|
|
139
|
+
this.fromVersion,
|
|
140
|
+
this.toVersion
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
if (changelogSections.length === 0) {
|
|
144
|
+
contentEl.createEl("p", {
|
|
145
|
+
text: "No significant changes found in this update.",
|
|
146
|
+
cls: this.cls("whats-new-empty"),
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
const changelogContainer = contentEl.createDiv({
|
|
150
|
+
cls: this.cls("whats-new-content"),
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
const markdownContent = formatChangelogSections(changelogSections);
|
|
154
|
+
|
|
155
|
+
await MarkdownRenderer.render(
|
|
156
|
+
this.app,
|
|
157
|
+
markdownContent,
|
|
158
|
+
changelogContainer,
|
|
159
|
+
"/",
|
|
160
|
+
this.plugin
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
// Make external links clickable
|
|
164
|
+
this.makeExternalLinksClickable(changelogContainer);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Action buttons
|
|
168
|
+
const buttonContainer = contentEl.createDiv({
|
|
169
|
+
cls: this.cls("whats-new-buttons"),
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
// Full changelog button (optional)
|
|
173
|
+
if (this.config.links.changelog) {
|
|
174
|
+
const changelogBtn = buttonContainer.createEl("button", {
|
|
175
|
+
text: "Full Changelog",
|
|
176
|
+
});
|
|
177
|
+
changelogBtn.addEventListener("click", () => {
|
|
178
|
+
window.open(this.config.links.changelog, "_blank");
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// Documentation button (optional)
|
|
183
|
+
if (this.config.links.documentation) {
|
|
184
|
+
const docsBtn = buttonContainer.createEl("button", {
|
|
185
|
+
text: "Documentation",
|
|
186
|
+
});
|
|
187
|
+
docsBtn.addEventListener("click", () => {
|
|
188
|
+
window.open(this.config.links.documentation, "_blank");
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// Close button (always present)
|
|
193
|
+
const closeBtn = buttonContainer.createEl("button", {
|
|
194
|
+
text: "Close",
|
|
195
|
+
cls: this.cls("mod-cta"),
|
|
196
|
+
});
|
|
197
|
+
closeBtn.addEventListener("click", () => this.close());
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
onClose() {
|
|
201
|
+
this.contentEl.empty();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -2,31 +2,6 @@ import type { App } from "obsidian";
|
|
|
2
2
|
import { TFile } from "obsidian";
|
|
3
3
|
import type { Frontmatter, FrontmatterDiff } from "./frontmatter-diff";
|
|
4
4
|
|
|
5
|
-
export interface NexusPropertiesSettings {
|
|
6
|
-
excludedPropagatedProps?: string;
|
|
7
|
-
parentProp: string;
|
|
8
|
-
childrenProp: string;
|
|
9
|
-
relatedProp: string;
|
|
10
|
-
zettelIdProp: string;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function parseExcludedProps(settings: NexusPropertiesSettings): Set<string> {
|
|
14
|
-
const excludedPropsStr = settings.excludedPropagatedProps || "";
|
|
15
|
-
const userExcluded = excludedPropsStr
|
|
16
|
-
.split(",")
|
|
17
|
-
.map((prop) => prop.trim())
|
|
18
|
-
.filter((prop) => prop.length > 0);
|
|
19
|
-
|
|
20
|
-
const alwaysExcluded = [
|
|
21
|
-
settings.parentProp,
|
|
22
|
-
settings.childrenProp,
|
|
23
|
-
settings.relatedProp,
|
|
24
|
-
settings.zettelIdProp,
|
|
25
|
-
];
|
|
26
|
-
|
|
27
|
-
return new Set([...alwaysExcluded, ...userExcluded]);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
5
|
export async function applyFrontmatterChanges(
|
|
31
6
|
app: App,
|
|
32
7
|
targetPath: string,
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
interface VersionSection {
|
|
2
|
+
version: string;
|
|
3
|
+
content: string;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Parses changelog markdown content into version sections.
|
|
8
|
+
* Each section starts with "## X.Y.Z" heading.
|
|
9
|
+
*/
|
|
10
|
+
export function parseChangelog(changelogContent: string): VersionSection[] {
|
|
11
|
+
const sections: VersionSection[] = [];
|
|
12
|
+
const lines = changelogContent.split("\n");
|
|
13
|
+
|
|
14
|
+
let currentVersion: string | null = null;
|
|
15
|
+
let currentContent: string[] = [];
|
|
16
|
+
|
|
17
|
+
for (const line of lines) {
|
|
18
|
+
const versionMatch = line.match(/^##\s+(\d+\.\d+\.\d+)/);
|
|
19
|
+
|
|
20
|
+
if (versionMatch) {
|
|
21
|
+
if (currentVersion !== null) {
|
|
22
|
+
sections.push({
|
|
23
|
+
version: currentVersion,
|
|
24
|
+
content: currentContent.join("\n").trim(),
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
currentVersion = versionMatch[1];
|
|
29
|
+
currentContent = [];
|
|
30
|
+
} else if (currentVersion !== null) {
|
|
31
|
+
currentContent.push(line);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (currentVersion !== null && currentContent.length > 0) {
|
|
36
|
+
sections.push({
|
|
37
|
+
version: currentVersion,
|
|
38
|
+
content: currentContent.join("\n").trim(),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return sections;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Compares two semantic version strings.
|
|
47
|
+
* Returns:
|
|
48
|
+
* - negative if v1 < v2
|
|
49
|
+
* - 0 if v1 === v2
|
|
50
|
+
* - positive if v1 > v2
|
|
51
|
+
*/
|
|
52
|
+
function compareVersions(v1: string, v2: string): number {
|
|
53
|
+
const parts1 = v1.split(".").map(Number);
|
|
54
|
+
const parts2 = v2.split(".").map(Number);
|
|
55
|
+
|
|
56
|
+
for (let i = 0; i < Math.max(parts1.length, parts2.length); i++) {
|
|
57
|
+
const num1 = parts1[i] || 0;
|
|
58
|
+
const num2 = parts2[i] || 0;
|
|
59
|
+
|
|
60
|
+
if (num1 !== num2) {
|
|
61
|
+
return num1 - num2;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return 0;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Gets all changelog sections between fromVersion (exclusive) and toVersion (inclusive).
|
|
70
|
+
* Sections are returned in reverse chronological order (newest first).
|
|
71
|
+
*/
|
|
72
|
+
export function getChangelogSince(
|
|
73
|
+
changelogContent: string,
|
|
74
|
+
fromVersion: string,
|
|
75
|
+
toVersion: string
|
|
76
|
+
): VersionSection[] {
|
|
77
|
+
const allSections = parseChangelog(changelogContent);
|
|
78
|
+
|
|
79
|
+
return allSections.filter((section) => {
|
|
80
|
+
const isAfterFrom = compareVersions(section.version, fromVersion) > 0;
|
|
81
|
+
const isBeforeOrEqualTo = compareVersions(section.version, toVersion) <= 0;
|
|
82
|
+
return isAfterFrom && isBeforeOrEqualTo;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export function formatChangelogSections(sections: VersionSection[]): string {
|
|
87
|
+
if (sections.length === 0) {
|
|
88
|
+
return "No changes found.";
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return sections
|
|
92
|
+
.map((section) => {
|
|
93
|
+
// Escape Dataview inline queries to prevent parsing errors
|
|
94
|
+
const content = section.content.replace(/`=([^`]+)`/g, "`\\=$1`");
|
|
95
|
+
return `## ${section.version}\n\n${content}`;
|
|
96
|
+
})
|
|
97
|
+
.join("\n\n");
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export type { VersionSection };
|
package/src/string/index.ts
CHANGED