@real1ty-obsidian-plugins/utils 2.23.0 → 2.24.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 +57 -0
- package/dist/components/whats-new-modal.d.ts.map +1 -0
- package/dist/components/whats-new-modal.js +108 -0
- package/dist/components/whats-new-modal.js.map +1 -0
- 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 +175 -0
- 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,57 @@
|
|
|
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
|
+
onOpen(): Promise<void>;
|
|
55
|
+
onClose(): void;
|
|
56
|
+
}
|
|
57
|
+
//# 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;IAIR,MAAM;IAmGZ,OAAO;CAGP"}
|
|
@@ -0,0 +1,108 @@
|
|
|
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
|
+
onOpen() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
const { contentEl } = this;
|
|
31
|
+
contentEl.empty();
|
|
32
|
+
this.addCls(contentEl, "whats-new-modal");
|
|
33
|
+
// Header section
|
|
34
|
+
const header = contentEl.createDiv({ cls: this.cls("whats-new-header") });
|
|
35
|
+
header.createEl("h2", {
|
|
36
|
+
text: `${this.config.pluginName} updated to v${this.toVersion}`,
|
|
37
|
+
});
|
|
38
|
+
header.createEl("p", {
|
|
39
|
+
text: `Changes since v${this.fromVersion}`,
|
|
40
|
+
cls: this.cls("whats-new-subtitle"),
|
|
41
|
+
});
|
|
42
|
+
// Support section (optional)
|
|
43
|
+
if (this.config.links.support) {
|
|
44
|
+
const supportSection = contentEl.createDiv({
|
|
45
|
+
cls: this.cls("whats-new-support"),
|
|
46
|
+
});
|
|
47
|
+
supportSection.createEl("h3", { text: "Support My Work" });
|
|
48
|
+
const supportText = supportSection.createEl("p");
|
|
49
|
+
supportText.createSpan({ text: "If you enjoy using this plugin, please consider " });
|
|
50
|
+
supportText.createEl("a", {
|
|
51
|
+
text: "supporting my work",
|
|
52
|
+
href: this.config.links.support,
|
|
53
|
+
});
|
|
54
|
+
supportText.createSpan({
|
|
55
|
+
text: ". Your support helps keep this plugin maintained and improved!",
|
|
56
|
+
});
|
|
57
|
+
contentEl.createEl("hr");
|
|
58
|
+
}
|
|
59
|
+
// Changelog content
|
|
60
|
+
const changelogSections = getChangelogSince(this.config.changelogContent, this.fromVersion, this.toVersion);
|
|
61
|
+
if (changelogSections.length === 0) {
|
|
62
|
+
contentEl.createEl("p", {
|
|
63
|
+
text: "No significant changes found in this update.",
|
|
64
|
+
cls: this.cls("whats-new-empty"),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
const changelogContainer = contentEl.createDiv({
|
|
69
|
+
cls: this.cls("whats-new-content"),
|
|
70
|
+
});
|
|
71
|
+
const markdownContent = formatChangelogSections(changelogSections);
|
|
72
|
+
yield MarkdownRenderer.render(this.app, markdownContent, changelogContainer, "/", this.plugin);
|
|
73
|
+
}
|
|
74
|
+
// Action buttons
|
|
75
|
+
const buttonContainer = contentEl.createDiv({
|
|
76
|
+
cls: this.cls("whats-new-buttons"),
|
|
77
|
+
});
|
|
78
|
+
// Full changelog button (optional)
|
|
79
|
+
if (this.config.links.changelog) {
|
|
80
|
+
const changelogBtn = buttonContainer.createEl("button", {
|
|
81
|
+
text: "Full Changelog",
|
|
82
|
+
});
|
|
83
|
+
changelogBtn.addEventListener("click", () => {
|
|
84
|
+
window.open(this.config.links.changelog, "_blank");
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// Documentation button (optional)
|
|
88
|
+
if (this.config.links.documentation) {
|
|
89
|
+
const docsBtn = buttonContainer.createEl("button", {
|
|
90
|
+
text: "Documentation",
|
|
91
|
+
});
|
|
92
|
+
docsBtn.addEventListener("click", () => {
|
|
93
|
+
window.open(this.config.links.documentation, "_blank");
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
// Close button (always present)
|
|
97
|
+
const closeBtn = buttonContainer.createEl("button", {
|
|
98
|
+
text: "Close",
|
|
99
|
+
cls: this.cls("mod-cta"),
|
|
100
|
+
});
|
|
101
|
+
closeBtn.addEventListener("click", () => this.close());
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
onClose() {
|
|
105
|
+
this.contentEl.empty();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# 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;QA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AAI,EAAE,gBAAgB;iBACtB,CAAC,CAAC;gBACH,YAAY,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;oBAC3C,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC;gBACpD,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,kCAAkC;YAClC,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;gBACrC,MAAM,OAAO,GAAG,eAAe,CAAC,QAAQ,CAAC,QAAQ,EAAE;oBAClD,IAAI,EAAE,eAAe;iBACrB,CAAC,CAAC;gBACH,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,GAAG,EAAE;oBACtC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;gBACxD,CAAC,CAAC,CAAC;YACJ,CAAC;YAED,gCAAgC;YAChC,MAAM,QAAQ,GAAG,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\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\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"]}
|
|
@@ -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,C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AC,MAAM,CAAC,CAAC;AAChB,CAAC","sourcesContent":["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,175 @@
|
|
|
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
|
+
async onOpen() {
|
|
74
|
+
const { contentEl } = this;
|
|
75
|
+
contentEl.empty();
|
|
76
|
+
|
|
77
|
+
this.addCls(contentEl, "whats-new-modal");
|
|
78
|
+
|
|
79
|
+
// Header section
|
|
80
|
+
const header = contentEl.createDiv({ cls: this.cls("whats-new-header") });
|
|
81
|
+
header.createEl("h2", {
|
|
82
|
+
text: `${this.config.pluginName} updated to v${this.toVersion}`,
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
header.createEl("p", {
|
|
86
|
+
text: `Changes since v${this.fromVersion}`,
|
|
87
|
+
cls: this.cls("whats-new-subtitle"),
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
// Support section (optional)
|
|
91
|
+
if (this.config.links.support) {
|
|
92
|
+
const supportSection = contentEl.createDiv({
|
|
93
|
+
cls: this.cls("whats-new-support"),
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
supportSection.createEl("h3", { text: "Support My Work" });
|
|
97
|
+
|
|
98
|
+
const supportText = supportSection.createEl("p");
|
|
99
|
+
supportText.createSpan({ text: "If you enjoy using this plugin, please consider " });
|
|
100
|
+
supportText.createEl("a", {
|
|
101
|
+
text: "supporting my work",
|
|
102
|
+
href: this.config.links.support,
|
|
103
|
+
});
|
|
104
|
+
supportText.createSpan({
|
|
105
|
+
text: ". Your support helps keep this plugin maintained and improved!",
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
contentEl.createEl("hr");
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// Changelog content
|
|
112
|
+
const changelogSections = getChangelogSince(
|
|
113
|
+
this.config.changelogContent,
|
|
114
|
+
this.fromVersion,
|
|
115
|
+
this.toVersion
|
|
116
|
+
);
|
|
117
|
+
|
|
118
|
+
if (changelogSections.length === 0) {
|
|
119
|
+
contentEl.createEl("p", {
|
|
120
|
+
text: "No significant changes found in this update.",
|
|
121
|
+
cls: this.cls("whats-new-empty"),
|
|
122
|
+
});
|
|
123
|
+
} else {
|
|
124
|
+
const changelogContainer = contentEl.createDiv({
|
|
125
|
+
cls: this.cls("whats-new-content"),
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
const markdownContent = formatChangelogSections(changelogSections);
|
|
129
|
+
|
|
130
|
+
await MarkdownRenderer.render(
|
|
131
|
+
this.app,
|
|
132
|
+
markdownContent,
|
|
133
|
+
changelogContainer,
|
|
134
|
+
"/",
|
|
135
|
+
this.plugin
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Action buttons
|
|
140
|
+
const buttonContainer = contentEl.createDiv({
|
|
141
|
+
cls: this.cls("whats-new-buttons"),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
// Full changelog button (optional)
|
|
145
|
+
if (this.config.links.changelog) {
|
|
146
|
+
const changelogBtn = buttonContainer.createEl("button", {
|
|
147
|
+
text: "Full Changelog",
|
|
148
|
+
});
|
|
149
|
+
changelogBtn.addEventListener("click", () => {
|
|
150
|
+
window.open(this.config.links.changelog, "_blank");
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Documentation button (optional)
|
|
155
|
+
if (this.config.links.documentation) {
|
|
156
|
+
const docsBtn = buttonContainer.createEl("button", {
|
|
157
|
+
text: "Documentation",
|
|
158
|
+
});
|
|
159
|
+
docsBtn.addEventListener("click", () => {
|
|
160
|
+
window.open(this.config.links.documentation, "_blank");
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Close button (always present)
|
|
165
|
+
const closeBtn = buttonContainer.createEl("button", {
|
|
166
|
+
text: "Close",
|
|
167
|
+
cls: this.cls("mod-cta"),
|
|
168
|
+
});
|
|
169
|
+
closeBtn.addEventListener("click", () => this.close());
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
onClose() {
|
|
173
|
+
this.contentEl.empty();
|
|
174
|
+
}
|
|
175
|
+
}
|
|
@@ -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