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

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.26",
4
+ "version": "0.1.28",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
package/dist/module.mjs CHANGED
@@ -17,7 +17,39 @@ const module$1 = defineNuxtModule({
17
17
  });
18
18
  addImportsDir(resolver.resolve("runtime/composables"));
19
19
  addImportsDir(resolver.resolve("runtime/utils"));
20
- _nuxt.options.build.transpile.push("alfaaz", "js-yaml");
20
+ _nuxt.options.build.transpile.push(
21
+ "alfaaz",
22
+ "js-yaml",
23
+ "lezer-markdown-obsidian",
24
+ "markdown-it-obsidian-callouts"
25
+ );
26
+ const codemirrorPackages = [
27
+ "@codemirror/state",
28
+ "@codemirror/view",
29
+ "@codemirror/language",
30
+ "@codemirror/autocomplete",
31
+ "@codemirror/commands",
32
+ "@codemirror/lang-markdown",
33
+ "@codemirror/lang-json",
34
+ "@codemirror/lang-yaml",
35
+ "@codemirror/language-data",
36
+ "@codemirror/search",
37
+ "@codemirror/lint",
38
+ "@lezer/common",
39
+ "@lezer/highlight",
40
+ "@lezer/markdown",
41
+ "codemirror",
42
+ "vue-codemirror6"
43
+ ];
44
+ _nuxt.hook("vite:extendConfig", (config) => {
45
+ config.resolve ??= {};
46
+ config.resolve.dedupe ??= [];
47
+ config.resolve.dedupe.push(...codemirrorPackages);
48
+ config.optimizeDeps ??= {};
49
+ config.optimizeDeps.include ??= [];
50
+ config.optimizeDeps.exclude ??= [];
51
+ config.optimizeDeps.exclude.push(...codemirrorPackages);
52
+ });
21
53
  _nuxt.options.alias["#codemirror-rich-obsidian-editor"] = resolver.resolve(
22
54
  "./runtime/editor/types"
23
55
  );
@@ -1,2 +1,12 @@
1
1
  import type { InternalLinkNode } from '../editor/types/editor-types.js';
2
+ /**
3
+ * Fast string-scanner implementation mirroring the exact rules of lezerInternalLinkParser.ts:
4
+ * - Matches [[ ... ]] and ![[...]] (embeds are included as regular links)
5
+ * - Disallows nested [[
6
+ * - Skips empty [[]]
7
+ * - Splits path on # for subpath
8
+ * - Splits on | for display alias
9
+ * - Skips over fenced code blocks (``` or ~~~) and inline code (`...`)
10
+ * to avoid matching [[ inside code
11
+ */
2
12
  export declare function getInternalLinks(markdownText: string): InternalLinkNode[];
@@ -1,28 +1,58 @@
1
- import { parseMarkdownToAST } from "./markdownParser.js";
2
1
  export function getInternalLinks(markdownText) {
3
2
  const links = [];
4
- const tree = parseMarkdownToAST(markdownText);
5
- tree.iterate({
6
- enter: (node) => {
7
- if (node.name === "InternalLink") {
8
- const link = { path: "" };
9
- const pathNode = node.node.getChild("InternalPath");
10
- if (pathNode) {
11
- link.path = markdownText.slice(pathNode.from, pathNode.to);
12
- }
13
- const subpathNode = node.node.getChild("InternalSubpath");
14
- if (subpathNode) {
15
- link.subpath = markdownText.slice(subpathNode.from, subpathNode.to);
16
- }
17
- const displayNode = node.node.getChild("InternalDisplay");
18
- if (displayNode) {
19
- link.display = markdownText.slice(displayNode.from, displayNode.to);
20
- }
21
- if (link.path) {
22
- links.push(link);
23
- }
3
+ const len = markdownText.length;
4
+ let i = 0;
5
+ while (i < len) {
6
+ const ch = markdownText[i];
7
+ if ((ch === "`" || ch === "~") && markdownText[i + 1] === ch && markdownText[i + 2] === ch) {
8
+ const fence = markdownText.slice(i, i + 3);
9
+ const end = markdownText.indexOf("\n" + fence, i + 3);
10
+ i = end === -1 ? len : end + 4;
11
+ continue;
12
+ }
13
+ if (ch === "`") {
14
+ const end = markdownText.indexOf("`", i + 1);
15
+ i = end === -1 ? len : end + 1;
16
+ continue;
17
+ }
18
+ const isEmbed = ch === "!" && markdownText[i + 1] === "[" && markdownText[i + 2] === "[";
19
+ const isLink = !isEmbed && ch === "[" && markdownText[i + 1] === "[";
20
+ if (!isEmbed && !isLink) {
21
+ i++;
22
+ continue;
23
+ }
24
+ const linkStart = isEmbed ? i + 1 : i;
25
+ const contentStart = linkStart + 2;
26
+ let endPos = -1;
27
+ let hasNestedOpen = false;
28
+ for (let j = contentStart; j < len - 1; j++) {
29
+ if (markdownText[j] === "[" && markdownText[j + 1] === "[") {
30
+ hasNestedOpen = true;
31
+ break;
24
32
  }
33
+ if (markdownText[j] === "]" && markdownText[j + 1] === "]") {
34
+ endPos = j;
35
+ break;
36
+ }
37
+ }
38
+ if (endPos === -1 || hasNestedOpen || endPos === contentStart) {
39
+ i = isEmbed ? i + 1 : i + 2;
40
+ continue;
41
+ }
42
+ const inner = markdownText.slice(contentStart, endPos);
43
+ const pipeIdx = inner.indexOf("|");
44
+ const pathRaw = pipeIdx === -1 ? inner : inner.slice(0, pipeIdx);
45
+ const display = pipeIdx === -1 ? void 0 : inner.slice(pipeIdx + 1).trim() || void 0;
46
+ const hashIdx = pathRaw.indexOf("#");
47
+ const path = (hashIdx === -1 ? pathRaw : pathRaw.slice(0, hashIdx)).trim();
48
+ const subpath = hashIdx === -1 ? void 0 : pathRaw.slice(hashIdx).trim() || void 0;
49
+ if (path) {
50
+ const link = { path };
51
+ if (subpath) link.subpath = subpath;
52
+ if (display) link.display = display;
53
+ links.push(link);
25
54
  }
26
- });
55
+ i = endPos + 2;
56
+ }
27
57
  return links;
28
58
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@type32/codemirror-rich-obsidian-editor",
3
- "version": "0.1.26",
3
+ "version": "0.1.28",
4
4
  "description": "OFM Editor Component for Nuxt.",
5
5
  "repository": "https://github.com/Type-32/codemirror-rich-obsidian",
6
6
  "license": "MIT",
@@ -35,6 +35,14 @@
35
35
  "test:types": "bunx vue-tsc --noEmit && cd playground && bunx vue-tsc --noEmit"
36
36
  },
37
37
  "dependencies": {
38
+ "@nuxt/kit": "^4.3.1",
39
+ "alfaaz": "^1.1.0",
40
+ "js-yaml": "^4.1.1",
41
+ "lezer-markdown-obsidian": "^0.0.3",
42
+ "markdown-it": "^14.1.1",
43
+ "markdown-it-obsidian-callouts": "^0.3.3"
44
+ },
45
+ "peerDependencies": {
38
46
  "@catppuccin/codemirror": "^1.0.3",
39
47
  "@codemirror/autocomplete": "^6.20.0",
40
48
  "@codemirror/lang-json": "^6.0.2",
@@ -44,43 +52,86 @@
44
52
  "@codemirror/language-data": "^6.5.2",
45
53
  "@codemirror/state": "^6.5.4",
46
54
  "@codemirror/theme-one-dark": "^6.1.3",
55
+ "@codemirror/view": "^6.0.0",
47
56
  "@hsorby/vue3-katex": "0.6.0-rc.7",
57
+ "@lezer/common": "^1.0.0",
48
58
  "@lezer/markdown": "^1.6.3",
49
- "@nuxt/image": "2.0.0",
50
- "@nuxt/kit": "^4.3.1",
51
59
  "@nuxt/ui": "^4.5.0",
52
60
  "@tiptap/extension-collaboration": "^3.20.0",
53
61
  "@tiptap/extension-node-range": "^3.20.0",
54
62
  "@tiptap/y-tiptap": "^3.0.2",
55
- "alfaaz": "^1.1.0",
56
63
  "codemirror": "^6.0.2",
57
- "js-yaml": "^4.1.1",
58
64
  "katex": "^0.16.33",
59
- "lezer-markdown-obsidian": "^0.0.3",
60
- "markdown-it": "^14.1.1",
61
- "markdown-it-obsidian-callouts": "^0.3.3",
62
65
  "tailwindcss": "^4.2.1",
63
66
  "vue-codemirror6": "^1.4.2",
64
67
  "yjs": "^13.6.29"
65
68
  },
69
+ "peerDependenciesMeta": {
70
+ "@catppuccin/codemirror": {
71
+ "optional": true
72
+ },
73
+ "@codemirror/theme-one-dark": {
74
+ "optional": true
75
+ },
76
+ "@hsorby/vue3-katex": {
77
+ "optional": true
78
+ },
79
+ "@tiptap/extension-collaboration": {
80
+ "optional": true
81
+ },
82
+ "@tiptap/extension-node-range": {
83
+ "optional": true
84
+ },
85
+ "@tiptap/y-tiptap": {
86
+ "optional": true
87
+ },
88
+ "katex": {
89
+ "optional": true
90
+ },
91
+ "yjs": {
92
+ "optional": true
93
+ }
94
+ },
66
95
  "devDependencies": {
96
+ "@catppuccin/codemirror": "^1.0.3",
97
+ "@codemirror/autocomplete": "^6.20.0",
98
+ "@codemirror/lang-json": "^6.0.2",
99
+ "@codemirror/lang-markdown": "^6.5.0",
100
+ "@codemirror/lang-yaml": "^6.1.2",
101
+ "@codemirror/language": "^6.12.2",
102
+ "@codemirror/language-data": "^6.5.2",
103
+ "@codemirror/state": "^6.5.4",
104
+ "@codemirror/theme-one-dark": "^6.1.3",
105
+ "@codemirror/view": "^6.0.0",
106
+ "@hsorby/vue3-katex": "0.6.0-rc.7",
67
107
  "@iconify-json/lucide": "^1.2.95",
68
108
  "@iconify-json/simple-icons": "^1.2.71",
109
+ "@lezer/common": "^1.0.0",
110
+ "@lezer/markdown": "^1.6.3",
69
111
  "@nuxt/devtools": "^3.2.2",
70
112
  "@nuxt/eslint-config": "^1.15.2",
71
113
  "@nuxt/fonts": "0.14.0",
72
114
  "@nuxt/icon": "2.2.1",
115
+ "@nuxt/image": "2.0.0",
73
116
  "@nuxt/module-builder": "^1.0.2",
74
117
  "@nuxt/schema": "^4.3.1",
75
118
  "@nuxt/test-utils": "^4.0.0",
119
+ "@tiptap/extension-collaboration": "^3.20.0",
120
+ "@tiptap/extension-node-range": "^3.20.0",
121
+ "@tiptap/y-tiptap": "^3.0.2",
76
122
  "@types/js-yaml": "^4.0.9",
77
123
  "@types/node": "^25.3.3",
78
124
  "changelogen": "^0.6.2",
125
+ "codemirror": "^6.0.2",
79
126
  "eslint": "^10.0.2",
127
+ "katex": "^0.16.33",
80
128
  "nuxt": "^4.3.1",
129
+ "tailwindcss": "^4.2.1",
81
130
  "typescript": "~5.9.3",
82
131
  "vitest": "^4.0.18",
83
- "vue-tsc": "^3.2.5"
132
+ "vue-codemirror6": "^1.4.2",
133
+ "vue-tsc": "^3.2.5",
134
+ "yjs": "^13.6.29"
84
135
  },
85
136
  "trustedDependencies": [
86
137
  "@parcel/watcher",