mirror of
https://github.com/vran-dev/obsidian-contribution-graph.git
synced 2026-07-22 09:20:23 +00:00
feat: use obsidian yaml function to instead of js-yaml library
This commit is contained in:
parent
16b0e91fb4
commit
9ef6599556
6 changed files with 20 additions and 30 deletions
|
|
@ -6,8 +6,7 @@
|
|||
|
||||
## What
|
||||
|
||||
Contribution Graph is a plugin for [obsidin.md](https://obsidian.md/) which could generate interactive contribution graphs like GitHub to track your notes, habits, activity, history, and so on.
|
||||
|
||||
Contribution Graph is a plugin for [obsidian.md](https://obsidian.md/) which could generate interactive heatmap graphs like GitHub to track your notes, habits, activity, history, and so on.
|
||||
|
||||
[](https://www.buymeacoffee.com/vran)
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
"name": "Contribution Graph",
|
||||
"version": "0.5.0",
|
||||
"minAppVersion": "1.3.0",
|
||||
"description": "generate interactive gitxxx style contribution graph for obsidian, use it to track your goals, habits, or anything else you want to track.",
|
||||
"description": "Generate a interactive headmap graph to visualize and track your productivity",
|
||||
"author": "vran",
|
||||
"authorUrl": "https://github.com/vran-dev",
|
||||
"isDesktopOnly": false,
|
||||
|
|
|
|||
24
package-lock.json
generated
24
package-lock.json
generated
|
|
@ -10,8 +10,6 @@
|
|||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@floating-ui/react": "^0.26.4",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"js-yaml": "^4.1.0",
|
||||
"luxon": "^3.4.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
|
|
@ -635,11 +633,6 @@
|
|||
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/@types/js-yaml": {
|
||||
"version": "4.0.9",
|
||||
"resolved": "https://registry.npmmirror.com/@types/js-yaml/-/js-yaml-4.0.9.tgz",
|
||||
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg=="
|
||||
},
|
||||
"node_modules/@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
|
|
@ -920,7 +913,9 @@
|
|||
"node_modules/argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true,
|
||||
"peer": true
|
||||
},
|
||||
"node_modules/array-union": {
|
||||
"version": "2.1.0",
|
||||
|
|
@ -1662,6 +1657,8 @@
|
|||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"dependencies": {
|
||||
"argparse": "^2.0.1"
|
||||
},
|
||||
|
|
@ -2775,11 +2772,6 @@
|
|||
"integrity": "sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==",
|
||||
"dev": true
|
||||
},
|
||||
"@types/js-yaml": {
|
||||
"version": "4.0.9",
|
||||
"resolved": "https://registry.npmmirror.com/@types/js-yaml/-/js-yaml-4.0.9.tgz",
|
||||
"integrity": "sha512-k4MGaQl5TGo/iipqb2UDG2UwjXziSWkh0uysQelTlJpX1qGlpUZYm8PnO4DxG1qBomtJUdYJ6qR6xdIah10JLg=="
|
||||
},
|
||||
"@types/json-schema": {
|
||||
"version": "7.0.15",
|
||||
"resolved": "https://registry.npmmirror.com/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||
|
|
@ -2989,7 +2981,9 @@
|
|||
"argparse": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmmirror.com/argparse/-/argparse-2.0.1.tgz",
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q=="
|
||||
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
|
||||
"dev": true,
|
||||
"peer": true
|
||||
},
|
||||
"array-union": {
|
||||
"version": "2.1.0",
|
||||
|
|
@ -3594,6 +3588,8 @@
|
|||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmmirror.com/js-yaml/-/js-yaml-4.1.0.tgz",
|
||||
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
|
||||
"dev": true,
|
||||
"peer": true,
|
||||
"requires": {
|
||||
"argparse": "^2.0.1"
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,8 +27,6 @@
|
|||
},
|
||||
"dependencies": {
|
||||
"@floating-ui/react": "^0.26.4",
|
||||
"@types/js-yaml": "^4.0.9",
|
||||
"js-yaml": "^4.1.0",
|
||||
"luxon": "^3.4.4",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0"
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
import { App, MarkdownPostProcessorContext } from "obsidian";
|
||||
import { load } from "js-yaml";
|
||||
import { App, MarkdownPostProcessorContext, parseYaml } from "obsidian";
|
||||
import { Renders } from "src/render/renders";
|
||||
|
||||
import { MISS_CONFIG } from "./bizErrors";
|
||||
|
|
@ -70,7 +69,7 @@ export class CodeBlockProcessor {
|
|||
|
||||
try {
|
||||
// @ts-ignore
|
||||
const yamlConfig: YamlGraphConfig = load(code);
|
||||
const yamlConfig: YamlGraphConfig = parseYaml(code);
|
||||
return YamlConfigReconciler.reconcile(yamlConfig);
|
||||
} catch (e) {
|
||||
if (e.mark?.line) {
|
||||
|
|
|
|||
|
|
@ -1,9 +1,7 @@
|
|||
import { Modal, App, MarkdownView } from "obsidian";
|
||||
import { Modal, App, MarkdownView, parseYaml, stringifyYaml } from "obsidian";
|
||||
import { StrictMode } from "react";
|
||||
import { Root, createRoot } from "react-dom/client";
|
||||
import { dump, load } from "js-yaml";
|
||||
import { CreateContributionGraphForm } from "./GraphForm";
|
||||
import { DataSource } from "src/query/types";
|
||||
import { YamlGraphConfig } from "src/processor/types";
|
||||
import { YamlConfigReconciler } from "src/processor/yamlConfigReconciler";
|
||||
|
||||
|
|
@ -50,7 +48,7 @@ export class ContributionGraphCreateModal extends Modal {
|
|||
// update existing Graph
|
||||
onSubmit = (yamlGraphConfig: YamlGraphConfig) => {
|
||||
this.close();
|
||||
this.onSave!(dump(yamlGraphConfig));
|
||||
this.onSave!(stringifyYaml(yamlGraphConfig));
|
||||
};
|
||||
} else {
|
||||
// create new Graph
|
||||
|
|
@ -63,9 +61,9 @@ export class ContributionGraphCreateModal extends Modal {
|
|||
const editor = markdownView.editor;
|
||||
this.close();
|
||||
if (ignoreLanguagePrefix) {
|
||||
editor.replaceSelection(dump(yamlGraphConfig));
|
||||
editor.replaceSelection(stringifyYaml(yamlGraphConfig));
|
||||
} else {
|
||||
const codeblock = `\`\`\`contributionGraph\n${dump(
|
||||
const codeblock = `\`\`\`contributionGraph\n${stringifyYaml(
|
||||
yamlGraphConfig
|
||||
)}\n\`\`\`\n`;
|
||||
editor.replaceSelection(codeblock);
|
||||
|
|
@ -99,7 +97,7 @@ export class ContributionGraphCreateModal extends Modal {
|
|||
this.originalConfigContent.trim() != ""
|
||||
) {
|
||||
try {
|
||||
return load(this.originalConfigContent) as YamlGraphConfig;
|
||||
return parseYaml(this.originalConfigContent) as YamlGraphConfig;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -118,7 +116,7 @@ export class ContributionGraphCreateModal extends Modal {
|
|||
const selection = editor.getSelection();
|
||||
if (selection && selection.trim() != "") {
|
||||
try {
|
||||
return load(selection) as YamlGraphConfig;
|
||||
return parseYaml(selection) as YamlGraphConfig;
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue