astro-md-editor 0.0.4 → 0.0.6

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "date": "2026-03-08T01:34:08.005Z",
2
+ "date": "2026-03-08T06:14:34.256Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -618,15 +618,15 @@ const manifest = { "e3ae5ae6db5120d43fecff71cd0258cb4a93807a1a382949ccd189596d19
618
618
  }, "c9dff6ed7373b505d6aeeb84c63f87a0d0c205051d9d817929a5b500e5e79e03": {
619
619
  functionName: "listCollectionIconsServerFn_createServerFn_handler",
620
620
  importer: () => import("./IconPickerPopover-fNUx2jAc.mjs")
621
+ }, "8346edc0b9da2addd68ca674ed9b2030f439d40deb713c45ef88393f5bdb91b9": {
622
+ functionName: "getLocalImagePreviewServerFn_createServerFn_handler",
623
+ importer: () => import("./image-preview.api-pcN5PQhH.mjs")
621
624
  }, "dcd3839820feeaed3b1a4f86186dd05c2e7e26ffaacdeaba309f44d121c95ad1": {
622
625
  functionName: "listFileHistoryServerFn_createServerFn_handler",
623
626
  importer: () => import("./file-history.api-oydnxFVV.mjs")
624
627
  }, "02ba027930daf730cf535415a08fab7365d58edddcc678dbcb19c72f990c25b5": {
625
628
  functionName: "readFileRevisionServerFn_createServerFn_handler",
626
629
  importer: () => import("./file-history.api-oydnxFVV.mjs")
627
- }, "8346edc0b9da2addd68ca674ed9b2030f439d40deb713c45ef88393f5bdb91b9": {
628
- functionName: "getLocalImagePreviewServerFn_createServerFn_handler",
629
- importer: () => import("./image-preview.api-pcN5PQhH.mjs")
630
630
  } };
631
631
  async function getServerFnById(id) {
632
632
  const serverFnInfo = manifest[id];
@@ -100,105 +100,105 @@ const assets = {
100
100
  "/favicon.ico": {
101
101
  "type": "image/vnd.microsoft.icon",
102
102
  "etag": '"f1e-ESBTjHetHyiokkO0tT/irBbMO8Y"',
103
- "mtime": "2026-03-08T01:34:03.121Z",
103
+ "mtime": "2026-03-08T06:14:29.202Z",
104
104
  "size": 3870,
105
105
  "path": "../public/favicon.ico"
106
106
  },
107
107
  "/logo192.png": {
108
108
  "type": "image/png",
109
109
  "etag": '"14e3-f08taHgqf6/O2oRVTsq5tImHdQA"',
110
- "mtime": "2026-03-08T01:34:03.121Z",
110
+ "mtime": "2026-03-08T06:14:29.203Z",
111
111
  "size": 5347,
112
112
  "path": "../public/logo192.png"
113
113
  },
114
114
  "/logo512.png": {
115
115
  "type": "image/png",
116
116
  "etag": '"25c0-RpFfnQJpTtSb/HqVNJR2hBA9w/4"',
117
- "mtime": "2026-03-08T01:34:03.121Z",
117
+ "mtime": "2026-03-08T06:14:29.202Z",
118
118
  "size": 9664,
119
119
  "path": "../public/logo512.png"
120
120
  },
121
121
  "/robots.txt": {
122
122
  "type": "text/plain; charset=utf-8",
123
123
  "etag": '"43-BEzmj4PuhUNHX+oW9uOnPSihxtU"',
124
- "mtime": "2026-03-08T01:34:03.121Z",
124
+ "mtime": "2026-03-08T06:14:29.203Z",
125
125
  "size": 67,
126
126
  "path": "../public/robots.txt"
127
127
  },
128
128
  "/manifest.json": {
129
129
  "type": "application/json",
130
130
  "etag": '"1f2-Oqn/x1R1hBTtEjA8nFhpBeFJJNg"',
131
- "mtime": "2026-03-08T01:34:03.121Z",
131
+ "mtime": "2026-03-08T06:14:29.202Z",
132
132
  "size": 498,
133
133
  "path": "../public/manifest.json"
134
134
  },
135
- "/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2": {
135
+ "/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2": {
136
136
  "type": "font/woff2",
137
- "etag": '"2be0-BP5iTzJeB8nLqYAgKpWNi5o1Zm8"',
138
- "mtime": "2026-03-08T01:34:02.637Z",
139
- "size": 11232,
140
- "path": "../public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2"
137
+ "etag": '"6568-cF1iUGbboMFZ8TfnP5HiMgl9II0"',
138
+ "mtime": "2026-03-08T06:14:28.718Z",
139
+ "size": 25960,
140
+ "path": "../public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2"
141
141
  },
142
142
  "/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2": {
143
143
  "type": "font/woff2",
144
144
  "etag": '"493c-n3Oy9D6jvzfMjpClqox+Zo7ERQQ"',
145
- "mtime": "2026-03-08T01:34:02.637Z",
145
+ "mtime": "2026-03-08T06:14:28.718Z",
146
146
  "size": 18748,
147
147
  "path": "../public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2"
148
148
  },
149
- "/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2": {
150
- "type": "font/woff2",
151
- "etag": '"6568-cF1iUGbboMFZ8TfnP5HiMgl9II0"',
152
- "mtime": "2026-03-08T01:34:02.637Z",
153
- "size": 25960,
154
- "path": "../public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2"
155
- },
156
- "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": {
149
+ "/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2": {
157
150
  "type": "font/woff2",
158
- "etag": '"bc80-8R1ym7Ck2DUNLqPQ/AYs9u8tUpg"',
159
- "mtime": "2026-03-08T01:34:02.637Z",
160
- "size": 48256,
161
- "path": "../public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2"
151
+ "etag": '"2be0-BP5iTzJeB8nLqYAgKpWNi5o1Zm8"',
152
+ "mtime": "2026-03-08T06:14:28.718Z",
153
+ "size": 11232,
154
+ "path": "../public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2"
162
155
  },
163
- "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": {
156
+ "/assets/inter-greek-wght-normal-CkhJZR-_.woff2": {
164
157
  "type": "font/woff2",
165
- "etag": '"14c4c-zz61D7IQFMB9QxHvTAOk/Vh4ibQ"',
166
- "mtime": "2026-03-08T01:34:02.637Z",
167
- "size": 85068,
168
- "path": "../public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2"
158
+ "etag": '"4a34-xor/hj4YNqI52zFecXnUbzQ4Xs4"',
159
+ "mtime": "2026-03-08T06:14:28.718Z",
160
+ "size": 18996,
161
+ "path": "../public/assets/inter-greek-wght-normal-CkhJZR-_.woff2"
169
162
  },
170
163
  "/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2": {
171
164
  "type": "font/woff2",
172
165
  "etag": '"280c-nBythjoDQ0+5wVAendJ6wU7Xz2M"',
173
- "mtime": "2026-03-08T01:34:02.637Z",
166
+ "mtime": "2026-03-08T06:14:28.718Z",
174
167
  "size": 10252,
175
168
  "path": "../public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2"
176
169
  },
177
- "/assets/inter-greek-wght-normal-CkhJZR-_.woff2": {
170
+ "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": {
178
171
  "type": "font/woff2",
179
- "etag": '"4a34-xor/hj4YNqI52zFecXnUbzQ4Xs4"',
180
- "mtime": "2026-03-08T01:34:02.637Z",
181
- "size": 18996,
182
- "path": "../public/assets/inter-greek-wght-normal-CkhJZR-_.woff2"
172
+ "etag": '"14c4c-zz61D7IQFMB9QxHvTAOk/Vh4ibQ"',
173
+ "mtime": "2026-03-08T06:14:28.718Z",
174
+ "size": 85068,
175
+ "path": "../public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2"
183
176
  },
184
- "/assets/main-DzXOjsqg.js": {
185
- "type": "text/javascript; charset=utf-8",
186
- "etag": '"59339-tSYXNZ6CNL1Zt0KVnL8TeohfAog"',
187
- "mtime": "2026-03-08T01:34:02.637Z",
188
- "size": 365369,
189
- "path": "../public/assets/main-DzXOjsqg.js"
177
+ "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": {
178
+ "type": "font/woff2",
179
+ "etag": '"bc80-8R1ym7Ck2DUNLqPQ/AYs9u8tUpg"',
180
+ "mtime": "2026-03-08T06:14:28.718Z",
181
+ "size": 48256,
182
+ "path": "../public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2"
190
183
  },
191
184
  "/assets/styles-CezfLgHY.css": {
192
185
  "type": "text/css; charset=utf-8",
193
186
  "etag": '"16c03-6spcY0zAbMWYIfx4MkgUIWefXb0"',
194
- "mtime": "2026-03-08T01:34:02.637Z",
187
+ "mtime": "2026-03-08T06:14:28.718Z",
195
188
  "size": 93187,
196
189
  "path": "../public/assets/styles-CezfLgHY.css"
197
190
  },
191
+ "/assets/main-DzXOjsqg.js": {
192
+ "type": "text/javascript; charset=utf-8",
193
+ "etag": '"59339-tSYXNZ6CNL1Zt0KVnL8TeohfAog"',
194
+ "mtime": "2026-03-08T06:14:28.718Z",
195
+ "size": 365369,
196
+ "path": "../public/assets/main-DzXOjsqg.js"
197
+ },
198
198
  "/assets/index-UQt6zCrS.js": {
199
199
  "type": "text/javascript; charset=utf-8",
200
200
  "etag": '"fd680-MTEy4A2zDMKeSP7AuzGHvXOYiSs"',
201
- "mtime": "2026-03-08T01:34:02.637Z",
201
+ "mtime": "2026-03-08T06:14:28.718Z",
202
202
  "size": 1037952,
203
203
  "path": "../public/assets/index-UQt6zCrS.js"
204
204
  }
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Bibek Timsina
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -2,38 +2,38 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/astro-md-editor.svg)](https://www.npmjs.com/package/astro-md-editor)
4
4
 
5
- Editor UI for Astro content collections (`src/content`) with schema-aware frontmatter editing and markdown body editing.
5
+ Schema-aware editor for Astro content collections. It lets you edit frontmatter and markdown/MDX together, validates on save, and can reuse values from file Git history.
6
6
 
7
- ## Run
7
+ Demo video: https://www.youtube.com/watch?v=-cI6ct8yLHM
8
8
 
9
- ```bash
10
- npx astro-md-editor
11
- ```
9
+ https://github.com/user-attachments/assets/7f38b6a4-fe1a-4e30-80c8-19a58aa860f1
10
+
11
+ ## Quick start
12
12
 
13
13
  ```bash
14
- pnpm dlx astro-md-editor
14
+ npx astro-md-editor
15
15
  # or
16
- pnpx astro-md-editor
16
+ pnpm dlx astro-md-editor
17
17
  ```
18
18
 
19
- ### Target project path
19
+ By default, it targets the current directory.
20
20
 
21
- ```bash
22
- # positional
23
- npx astro-md-editor /absolute/path/to/astro-project
21
+ Target a specific Astro project:
24
22
 
25
- # flag
26
- npx astro-md-editor --path /absolute/path/to/astro-project
23
+ ```bash
24
+ astro-md-editor /absolute/path/to/astro-project
25
+ # or
26
+ astro-md-editor --path /absolute/path/to/astro-project
27
27
  ```
28
28
 
29
- Path resolution order:
29
+ Root resolution order:
30
30
 
31
- 1. positional CLI arg (`astro-md-editor <astro-project-root>`)
32
- 2. `--path=<astro-project-root>`
31
+ 1. positional argument (`astro-md-editor <astro-project-root>`)
32
+ 2. `--path`
33
33
  3. `APP_ROOT_PATH`
34
34
  4. current working directory
35
35
 
36
- ### Port
36
+ Port can be set with `PORT` or `NITRO_PORT`.
37
37
 
38
38
  ```bash
39
39
  PORT=1234 npx astro-md-editor
@@ -41,54 +41,29 @@ PORT=1234 npx astro-md-editor
41
41
  NITRO_PORT=1234 npx astro-md-editor
42
42
  ```
43
43
 
44
- The runtime reads `PORT`/`NITRO_PORT` for server port.
45
-
46
44
  ## Requirements
47
45
 
48
- - Astro project with collections in `src/content`.
49
- - Collection schemas available in `.astro/collections/*.schema.json`.
46
+ - Astro project with collections under `src/content`
47
+ - Generated collection schemas in `.astro/collections/*.schema.json`
50
48
 
51
- If schema files are missing, run:
49
+ If schema files are missing, run in the target project:
52
50
 
53
51
  ```bash
54
52
  astro sync
55
53
  ```
56
54
 
57
- ## Features
58
-
59
- - Reads `.astro/collections/*.schema.json`.
60
- - Scans `src/content/<collection>/**/*.{md,mdx,markdown}`.
61
- - Renders controls for schema fields (`string`, `number`, `boolean`, `enum`, `date`, arrays).
62
- - Edits frontmatter and markdown/MDX body in one flow.
63
- - Validates frontmatter with AJV before save.
64
- - Supports image field inference from `src/content.config.*` (`image()`, `z.array(image())`).
65
- - Supports image pickers for both `src` assets and `public` assets.
66
- - Includes a per-file Git History tab in the right sidebar (timeline-style commit list).
67
- - Shows commit message, author, and time; expands each item to inspect revision frontmatter.
68
- - Can apply a selected revision into the current draft with schema-safe frontmatter reapply (incompatible keys are skipped).
69
- - Applying history updates only the in-editor draft; normal Save flow still controls disk writes.
55
+ ## Highlights
70
56
 
71
- ## Local development
72
-
73
- ```bash
74
- pnpm dev
75
- ```
57
+ - Reads collection schemas and content files (`.md`, `.mdx`, `.markdown`)
58
+ - Renders schema-aware controls (`string`, `number`, `boolean`, `enum`, `date`, arrays)
59
+ - Validates frontmatter with AJV before saving
60
+ - Infers image fields from `src/content.config.*` (`image()` / `z.array(image())`)
61
+ - Supports image pickers for both `src` assets and `public` assets
62
+ - Shows per-file Git history and applies selected revision values to the current draft safely
76
63
 
77
- `pnpm dev` uses `--path example-blog --port 3000`.
64
+ ## Field overrides (optional)
78
65
 
79
- Run dev against another project:
80
-
81
- ```bash
82
- node scripts/dev.mjs /absolute/path/to/astro-project --port 3000
83
- ```
84
-
85
- In dev mode, startup always runs `astro sync` for the selected project before loading collections.
86
-
87
- ## Field overrides
88
-
89
- Create `astro-md-editor.fields.json` at the Astro project root.
90
-
91
- Example:
66
+ Create `astro-md-editor.fields.json` at the Astro project root to force specific UI controls.
92
67
 
93
68
  ```json
94
69
  {
@@ -104,32 +79,48 @@ Example:
104
79
  }
105
80
  ```
106
81
 
107
- Rules:
82
+ Supported override types:
108
83
 
109
- - `type`: `image`, `color`, or `icon`
110
- - for `type: "image"`, optional `mode`: `asset` (default) or `public`
111
- - for `type: "image"`, optional `multiple: true` for array-style image input
112
- - for `type: "icon"`, optional `icon_libraries: string[]` to restrict picker libraries by Iconify prefix
113
- - shape: `{ [collectionName]: { [fieldName]: override } }`
84
+ - `image` (`mode: "asset" | "public"`, optional `multiple: true`)
85
+ - `color`
86
+ - `icon` (optional `icon_libraries: string[]`)
114
87
 
115
- Precedence:
88
+ Precedence: `astro-md-editor.fields.json` > inferred `image()` fields > schema defaults.
116
89
 
117
- 1. `astro-md-editor.fields.json` overrides
118
- 2. inferred `image()` / `array(image())` from content config
119
- 3. schema-based fallback rendering
90
+ Invalid or schema-incompatible overrides are ignored with startup warnings.
120
91
 
121
- Invalid or incompatible overrides are ignored with bootstrap warnings.
92
+ ## Notes
122
93
 
123
- ### Example blog demo
94
+ - Applying Git history updates the in-editor draft only; files are written only on normal Save
95
+ - `public` assets are saved as `/path/from/public`
96
+ - `src` assets are saved relative to the edited content file (`./...` or `../...`)
97
+ - Icon values are saved as Iconify IDs (for example `lucide:messages-square`)
98
+ - Custom controls currently target top-level frontmatter fields
124
99
 
125
- `example-blog` includes icon override samples in the `blog` collection:
100
+ ## Add a custom UI handler in code
126
101
 
127
- - `menuIconFiltered`: icon picker restricted to `lucide` and `mdi`
128
- - `menuIconAny`: icon picker with all Iconify libraries
102
+ If you are extending the editor itself (not just using `astro-md-editor.fields.json`), add a new field kind in these places:
129
103
 
130
- ## Notes
104
+ 1. `src/lib/schema-form.ts`
105
+ - Extend `FieldUiKind`, `FieldUiConfig`, and `ResolvedField`
106
+ - Update `resolveCustomFieldKind` to map your override kind to a resolved field
107
+
108
+ 2. `scripts/bootstrap-collections.mjs`
109
+ - Extend `fieldOverrideSchema` so config accepts your new `type`
110
+ - Update `getOverrideConfig` and `resolveSchemaCompatibilityKind`
111
+
112
+ 3. `src/components/editor/RightSidebar.tsx`
113
+ - Add your new field component
114
+ - Render it in the `resolvedFields.map(...)` switch (`field.kind === '<yourKind>'`)
115
+
116
+ 4. `src/lib/frontmatter-history-merge.ts`
117
+ - Update `isCompatibleValue` so Git-history apply validates your new kind correctly
118
+
119
+ Quick checklist for a new kind (example: `slug`):
120
+
121
+ - add `slug` to schema/field types
122
+ - parse `type: "slug"` in bootstrap overrides
123
+ - render `<SlugField />` in `RightSidebar`
124
+ - add compatibility logic in history merge
131
125
 
132
- - `public` assets are saved as `/path/from/public`.
133
- - `src` assets are saved as relative paths from the content file (`./...` or `../...`).
134
- - `icon` values are saved as Iconify strings like `lucide:messages-square`.
135
- - Custom controls currently target top-level frontmatter fields.
126
+ If any part is missing, the field falls back to default/unsupported handling.
package/package.json CHANGED
@@ -1,6 +1,29 @@
1
1
  {
2
2
  "name": "astro-md-editor",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
+ "description": "Schema-aware editor for Astro content collections.",
5
+ "author": "Bibek Timsina",
6
+ "license": "MIT",
7
+ "keywords": [
8
+ "astro",
9
+ "markdown",
10
+ "mdx",
11
+ "content-collections",
12
+ "editor",
13
+ "cli"
14
+ ],
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/bimsina/astro-md-editor.git"
18
+ },
19
+ "homepage": "https://github.com/bimsina/astro-md-editor#readme",
20
+ "bugs": {
21
+ "url": "https://github.com/bimsina/astro-md-editor/issues"
22
+ },
23
+ "engines": {
24
+ "node": ">=20"
25
+ },
26
+ "packageManager": "pnpm@10.28.2",
4
27
  "private": false,
5
28
  "type": "module",
6
29
  "bin": {
@@ -10,7 +33,8 @@
10
33
  ".output/",
11
34
  "index.mjs",
12
35
  "scripts/bootstrap-collections.mjs",
13
- "README.md"
36
+ "README.md",
37
+ "LICENSE.md"
14
38
  ],
15
39
  "imports": {
16
40
  "#/*": "./src/*"