@type32/codemirror-rich-obsidian-editor 0.1.23 → 0.1.26

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/README.md CHANGED
@@ -19,7 +19,7 @@
19
19
  - https://github.com/nothingislost/obsidian-cm6-attributes
20
20
 
21
21
  ## Disclaimer
22
- I have used Gemini 2.5 Pro + Gemini 3 Pro Preview + Claude Sonnet 4.5 in the process of developing this editor numerous times, so do expect errors or inconsistencies in some parts of the code.
22
+ I have used Gemini 2.5 Pro + Gemini 3 Pro Preview + Claude Sonnet 4.5 + Claude Sonnet 4.6 in the process of developing this editor numerous times, so do expect errors or inconsistencies in some parts of the code.
23
23
 
24
24
  ## Introduction
25
25
  Do I even need an intro?
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@type32/codemirror-rich-obsidian-editor",
3
3
  "configKey": "cmOfmEditor",
4
- "version": "0.1.23",
4
+ "version": "0.1.26",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,6 +1,5 @@
1
- import { dump } from "js-yaml";
2
1
  import { useEditorUtils } from "./useEditorUtils.js";
3
- import { parseFrontmatter } from "../utils/frontmatter.js";
2
+ import { parseFrontmatter, stringifyYaml } from "../utils/frontmatter.js";
4
3
  export function useEditorFrontmatter(editor) {
5
4
  const editorUtils = useEditorUtils(editor);
6
5
  function getFrontmatter() {
@@ -71,9 +70,13 @@ export function useEditorFrontmatter(editor) {
71
70
  }
72
71
  return false;
73
72
  }
74
- const newYamlContent = dump(newData, { skipInvalid: true }).trim();
73
+ const yamlResult = stringifyYaml(newData);
74
+ if (yamlResult.error) {
75
+ console.error("Error converting data to YAML:", yamlResult.error);
76
+ return false;
77
+ }
75
78
  const newFrontmatterBlock = `---
76
- ${newYamlContent}
79
+ ${yamlResult.yaml}
77
80
  ---`;
78
81
  if (hasFrontmatter) {
79
82
  editorUtils.dispatch({
@@ -1 +1,2 @@
1
- export declare const editorInternalLinkAutocompletePlugin: import("@codemirror/state").Extension;
1
+ import type { Extension } from "@codemirror/state";
2
+ export declare const editorInternalLinkAutocompletePlugin: Extension;
@@ -1,4 +1,50 @@
1
1
  import type { Frontmatter } from '../editor/types/editor-types.js';
2
+ /**
3
+ * Converts a JavaScript object/data into a YAML string suitable for writing to files.
4
+ *
5
+ * @param data - The data to convert to YAML
6
+ * @param options - Optional formatting options
7
+ * @returns YAML string or error object
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * interface Config {
12
+ * title: string
13
+ * count: number
14
+ * tags: string[]
15
+ * }
16
+ *
17
+ * const data: Config = {
18
+ * title: 'Hello',
19
+ * count: 42,
20
+ * tags: ['vue', 'nuxt']
21
+ * }
22
+ *
23
+ * const result = stringifyYaml(data)
24
+ * if (result.yaml) {
25
+ * console.log(result.yaml)
26
+ * // Output:
27
+ * // title: Hello
28
+ * // count: 42
29
+ * // tags:
30
+ * // - vue
31
+ * // - nuxt
32
+ * }
33
+ * ```
34
+ */
35
+ export declare function stringifyYaml(data: any, options?: {
36
+ /** Number of spaces for indentation (default: 2) */
37
+ indent?: number;
38
+ /** Skip invalid types instead of throwing (default: true) */
39
+ skipInvalid?: boolean;
40
+ /** Maximum line width (default: 80) */
41
+ lineWidth?: number;
42
+ /** Sort object keys (default: false) */
43
+ sortKeys?: boolean;
44
+ }): {
45
+ yaml?: string;
46
+ error?: Error;
47
+ };
2
48
  /**
3
49
  * Parses a YAML/YML string into the specified type.
4
50
  *
@@ -1,4 +1,20 @@
1
- import { load } from "js-yaml";
1
+ import { load, dump } from "js-yaml";
2
+ export function stringifyYaml(data, options) {
3
+ if (data === null || data === void 0) {
4
+ return { yaml: "" };
5
+ }
6
+ try {
7
+ const yaml = dump(data, {
8
+ indent: options?.indent ?? 2,
9
+ skipInvalid: options?.skipInvalid ?? true,
10
+ lineWidth: options?.lineWidth ?? 80,
11
+ sortKeys: options?.sortKeys ?? false
12
+ });
13
+ return { yaml: yaml.trim() };
14
+ } catch (e) {
15
+ return { error: e };
16
+ }
17
+ }
2
18
  export function parseYaml(yamlString) {
3
19
  if (!yamlString || yamlString.trim().length === 0) {
4
20
  return { data: {} };
@@ -1,9 +1,10 @@
1
+ import type { LanguageSupport } from '@codemirror/language';
1
2
  import type { Tree } from '@lezer/common';
2
3
  /**
3
4
  * Creates a markdown parser with standard OFM extensions
4
5
  * This configuration is used consistently across the codebase
5
6
  */
6
- export declare function createMarkdownParser(): import("@codemirror/language").LanguageSupport;
7
+ export declare function createMarkdownParser(): LanguageSupport;
7
8
  /**
8
9
  * Parses markdown text to AST using the standard OFM parser configuration
9
10
  * @param markdownText The markdown text to parse
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@type32/codemirror-rich-obsidian-editor",
3
- "version": "0.1.23",
3
+ "version": "0.1.26",
4
4
  "description": "OFM Editor Component for Nuxt.",
5
5
  "repository": "https://github.com/Type-32/codemirror-rich-obsidian",
6
6
  "license": "MIT",
@@ -35,51 +35,52 @@
35
35
  "test:types": "bunx vue-tsc --noEmit && cd playground && bunx vue-tsc --noEmit"
36
36
  },
37
37
  "dependencies": {
38
- "@catppuccin/codemirror": "^1.0.1",
38
+ "@catppuccin/codemirror": "^1.0.3",
39
39
  "@codemirror/autocomplete": "^6.20.0",
40
40
  "@codemirror/lang-json": "^6.0.2",
41
41
  "@codemirror/lang-markdown": "^6.5.0",
42
42
  "@codemirror/lang-yaml": "^6.1.2",
43
- "@codemirror/language": "^6.12.1",
43
+ "@codemirror/language": "^6.12.2",
44
44
  "@codemirror/language-data": "^6.5.2",
45
+ "@codemirror/state": "^6.5.4",
45
46
  "@codemirror/theme-one-dark": "^6.1.3",
46
47
  "@hsorby/vue3-katex": "0.6.0-rc.7",
47
48
  "@lezer/markdown": "^1.6.3",
48
49
  "@nuxt/image": "2.0.0",
49
- "@nuxt/kit": "^4.3.0",
50
- "@nuxt/ui": "^4.4.0",
51
- "@tiptap/extension-collaboration": "^3.18.0",
52
- "@tiptap/extension-node-range": "^3.18.0",
50
+ "@nuxt/kit": "^4.3.1",
51
+ "@nuxt/ui": "^4.5.0",
52
+ "@tiptap/extension-collaboration": "^3.20.0",
53
+ "@tiptap/extension-node-range": "^3.20.0",
53
54
  "@tiptap/y-tiptap": "^3.0.2",
54
55
  "alfaaz": "^1.1.0",
55
56
  "codemirror": "^6.0.2",
56
57
  "js-yaml": "^4.1.1",
57
- "katex": "^0.16.28",
58
+ "katex": "^0.16.33",
58
59
  "lezer-markdown-obsidian": "^0.0.3",
59
- "markdown-it": "^14.1.0",
60
+ "markdown-it": "^14.1.1",
60
61
  "markdown-it-obsidian-callouts": "^0.3.3",
61
- "tailwindcss": "^4.1.18",
62
- "vue-codemirror6": "^1.4.1",
62
+ "tailwindcss": "^4.2.1",
63
+ "vue-codemirror6": "^1.4.2",
63
64
  "yjs": "^13.6.29"
64
65
  },
65
66
  "devDependencies": {
66
- "@iconify-json/lucide": "^1.2.87",
67
- "@iconify-json/simple-icons": "^1.2.68",
68
- "@nuxt/devtools": "^3.1.1",
69
- "@nuxt/eslint-config": "^1.13.0",
70
- "@nuxt/fonts": "0.13.0",
67
+ "@iconify-json/lucide": "^1.2.95",
68
+ "@iconify-json/simple-icons": "^1.2.71",
69
+ "@nuxt/devtools": "^3.2.2",
70
+ "@nuxt/eslint-config": "^1.15.2",
71
+ "@nuxt/fonts": "0.14.0",
71
72
  "@nuxt/icon": "2.2.1",
72
73
  "@nuxt/module-builder": "^1.0.2",
73
- "@nuxt/schema": "^4.3.0",
74
- "@nuxt/test-utils": "^3.23.0",
74
+ "@nuxt/schema": "^4.3.1",
75
+ "@nuxt/test-utils": "^4.0.0",
75
76
  "@types/js-yaml": "^4.0.9",
76
- "@types/node": "^25.0.10",
77
+ "@types/node": "^25.3.3",
77
78
  "changelogen": "^0.6.2",
78
- "eslint": "^9.39.2",
79
- "nuxt": "^4.3.0",
79
+ "eslint": "^10.0.2",
80
+ "nuxt": "^4.3.1",
80
81
  "typescript": "~5.9.3",
81
82
  "vitest": "^4.0.18",
82
- "vue-tsc": "^3.2.4"
83
+ "vue-tsc": "^3.2.5"
83
84
  },
84
85
  "trustedDependencies": [
85
86
  "@parcel/watcher",