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

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/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.22",
4
+ "version": "0.1.23",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -5,8 +5,11 @@ const module$1 = defineNuxtModule({
5
5
  name: "@type32/codemirror-rich-obsidian-editor",
6
6
  configKey: "cmOfmEditor"
7
7
  },
8
- // Default configuration options of the Nuxt module
9
- defaults: {},
8
+ moduleDependencies: {
9
+ "@nuxt/ui": {
10
+ version: ">=4.4.0"
11
+ }
12
+ },
10
13
  setup(_options, _nuxt) {
11
14
  const resolver = createResolver(import.meta.url);
12
15
  addComponentsDir({
@@ -1,4 +1,28 @@
1
1
  import type { Frontmatter } from '../editor/types/editor-types.js';
2
+ /**
3
+ * Parses a YAML/YML string into the specified type.
4
+ *
5
+ * @param yamlString - The YAML string to parse
6
+ * @returns Parsed data or error object
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * interface Config {
11
+ * title: string
12
+ * count: number
13
+ * }
14
+ *
15
+ * const yaml = 'title: Hello\ncount: 42'
16
+ * const result = parseYaml<Config>(yaml)
17
+ * if (result.data) {
18
+ * console.log(result.data.title) // "Hello"
19
+ * }
20
+ * ```
21
+ */
22
+ export declare function parseYaml<T = any>(yamlString: string): {
23
+ data?: T;
24
+ error?: Error;
25
+ };
2
26
  /**
3
27
  * Lightning-fast frontmatter parser using string operations instead of AST parsing.
4
28
  * Optimized for performance - parses in microseconds instead of milliseconds.
@@ -1,4 +1,21 @@
1
1
  import { load } from "js-yaml";
2
+ export function parseYaml(yamlString) {
3
+ if (!yamlString || yamlString.trim().length === 0) {
4
+ return { data: {} };
5
+ }
6
+ try {
7
+ const data = load(yamlString);
8
+ if (data === null || data === void 0) {
9
+ return { data: {} };
10
+ }
11
+ if (typeof data === "object") {
12
+ return { data };
13
+ }
14
+ return { data };
15
+ } catch (e) {
16
+ return { error: e };
17
+ }
18
+ }
2
19
  export function parseFrontmatter(markdownText) {
3
20
  if (!markdownText) {
4
21
  return { error: new Error("No markdown text provided") };
@@ -20,16 +37,9 @@ export function parseFrontmatter(markdownText) {
20
37
  return { data: {} };
21
38
  }
22
39
  const yamlContent = markdownText.slice(yamlStart, closingFenceIndex);
23
- try {
24
- const data = load(yamlContent);
25
- if (data === null || data === void 0) {
26
- return { data: {} };
27
- }
28
- if (typeof data === "object") {
29
- return { data };
30
- }
40
+ const result = parseYaml(yamlContent);
41
+ if (result.data && typeof result.data !== "object") {
31
42
  return { error: new Error("Frontmatter is not a valid object.") };
32
- } catch (e) {
33
- return { error: e };
34
43
  }
44
+ return result;
35
45
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@type32/codemirror-rich-obsidian-editor",
3
- "version": "0.1.22",
3
+ "version": "0.1.23",
4
4
  "description": "OFM Editor Component for Nuxt.",
5
5
  "repository": "https://github.com/Type-32/codemirror-rich-obsidian",
6
6
  "license": "MIT",