astro-md-editor 0.0.4 → 0.0.5

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:10:30.750Z",
3
3
  "preset": "node-server",
4
4
  "framework": {
5
5
  "name": "nitro",
@@ -612,12 +612,6 @@ const manifest = { "e3ae5ae6db5120d43fecff71cd0258cb4a93807a1a382949ccd189596d19
612
612
  }, "1f487dcb5d0b909c2785163b904a0ee48e748b32783309e964b4502d83a2e7a7": {
613
613
  functionName: "getImageAssetPreview_createServerFn_handler",
614
614
  importer: () => import("./ImageAssetBrowser-DNDdTqtf.mjs")
615
- }, "3ba1a566c82090c8422dd6ca7258b2e1aed644206364441faf1bd80942f21745": {
616
- functionName: "listIconifyCollectionsServerFn_createServerFn_handler",
617
- importer: () => import("./IconPickerPopover-fNUx2jAc.mjs")
618
- }, "c9dff6ed7373b505d6aeeb84c63f87a0d0c205051d9d817929a5b500e5e79e03": {
619
- functionName: "listCollectionIconsServerFn_createServerFn_handler",
620
- importer: () => import("./IconPickerPopover-fNUx2jAc.mjs")
621
615
  }, "dcd3839820feeaed3b1a4f86186dd05c2e7e26ffaacdeaba309f44d121c95ad1": {
622
616
  functionName: "listFileHistoryServerFn_createServerFn_handler",
623
617
  importer: () => import("./file-history.api-oydnxFVV.mjs")
@@ -627,6 +621,12 @@ const manifest = { "e3ae5ae6db5120d43fecff71cd0258cb4a93807a1a382949ccd189596d19
627
621
  }, "8346edc0b9da2addd68ca674ed9b2030f439d40deb713c45ef88393f5bdb91b9": {
628
622
  functionName: "getLocalImagePreviewServerFn_createServerFn_handler",
629
623
  importer: () => import("./image-preview.api-pcN5PQhH.mjs")
624
+ }, "3ba1a566c82090c8422dd6ca7258b2e1aed644206364441faf1bd80942f21745": {
625
+ functionName: "listIconifyCollectionsServerFn_createServerFn_handler",
626
+ importer: () => import("./IconPickerPopover-fNUx2jAc.mjs")
627
+ }, "c9dff6ed7373b505d6aeeb84c63f87a0d0c205051d9d817929a5b500e5e79e03": {
628
+ functionName: "listCollectionIconsServerFn_createServerFn_handler",
629
+ importer: () => import("./IconPickerPopover-fNUx2jAc.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:10:25.839Z",
104
104
  "size": 3870,
105
105
  "path": "../public/favicon.ico"
106
106
  },
107
+ "/manifest.json": {
108
+ "type": "application/json",
109
+ "etag": '"1f2-Oqn/x1R1hBTtEjA8nFhpBeFJJNg"',
110
+ "mtime": "2026-03-08T06:10:25.839Z",
111
+ "size": 498,
112
+ "path": "../public/manifest.json"
113
+ },
107
114
  "/logo192.png": {
108
115
  "type": "image/png",
109
116
  "etag": '"14e3-f08taHgqf6/O2oRVTsq5tImHdQA"',
110
- "mtime": "2026-03-08T01:34:03.121Z",
117
+ "mtime": "2026-03-08T06:10:25.839Z",
111
118
  "size": 5347,
112
119
  "path": "../public/logo192.png"
113
120
  },
114
- "/logo512.png": {
115
- "type": "image/png",
116
- "etag": '"25c0-RpFfnQJpTtSb/HqVNJR2hBA9w/4"',
117
- "mtime": "2026-03-08T01:34:03.121Z",
118
- "size": 9664,
119
- "path": "../public/logo512.png"
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:10:25.839Z",
125
125
  "size": 67,
126
126
  "path": "../public/robots.txt"
127
127
  },
128
- "/manifest.json": {
129
- "type": "application/json",
130
- "etag": '"1f2-Oqn/x1R1hBTtEjA8nFhpBeFJJNg"',
131
- "mtime": "2026-03-08T01:34:03.121Z",
132
- "size": 498,
133
- "path": "../public/manifest.json"
128
+ "/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2": {
129
+ "type": "font/woff2",
130
+ "etag": '"493c-n3Oy9D6jvzfMjpClqox+Zo7ERQQ"',
131
+ "mtime": "2026-03-08T06:10:25.333Z",
132
+ "size": 18748,
133
+ "path": "../public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2"
134
134
  },
135
135
  "/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2": {
136
136
  "type": "font/woff2",
137
137
  "etag": '"2be0-BP5iTzJeB8nLqYAgKpWNi5o1Zm8"',
138
- "mtime": "2026-03-08T01:34:02.637Z",
138
+ "mtime": "2026-03-08T06:10:25.332Z",
139
139
  "size": 11232,
140
140
  "path": "../public/assets/inter-greek-ext-wght-normal-DlzME5K_.woff2"
141
141
  },
142
- "/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2": {
143
- "type": "font/woff2",
144
- "etag": '"493c-n3Oy9D6jvzfMjpClqox+Zo7ERQQ"',
145
- "mtime": "2026-03-08T01:34:02.637Z",
146
- "size": 18748,
147
- "path": "../public/assets/inter-cyrillic-wght-normal-DqGufNeO.woff2"
148
- },
149
142
  "/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2": {
150
143
  "type": "font/woff2",
151
144
  "etag": '"6568-cF1iUGbboMFZ8TfnP5HiMgl9II0"',
152
- "mtime": "2026-03-08T01:34:02.637Z",
145
+ "mtime": "2026-03-08T06:10:25.332Z",
153
146
  "size": 25960,
154
147
  "path": "../public/assets/inter-cyrillic-ext-wght-normal-BOeWTOD4.woff2"
155
148
  },
156
- "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": {
149
+ "/logo512.png": {
150
+ "type": "image/png",
151
+ "etag": '"25c0-RpFfnQJpTtSb/HqVNJR2hBA9w/4"',
152
+ "mtime": "2026-03-08T06:10:25.839Z",
153
+ "size": 9664,
154
+ "path": "../public/logo512.png"
155
+ },
156
+ "/assets/inter-greek-wght-normal-CkhJZR-_.woff2": {
157
157
  "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"
158
+ "etag": '"4a34-xor/hj4YNqI52zFecXnUbzQ4Xs4"',
159
+ "mtime": "2026-03-08T06:10:25.333Z",
160
+ "size": 18996,
161
+ "path": "../public/assets/inter-greek-wght-normal-CkhJZR-_.woff2"
162
162
  },
163
163
  "/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2": {
164
164
  "type": "font/woff2",
165
165
  "etag": '"14c4c-zz61D7IQFMB9QxHvTAOk/Vh4ibQ"',
166
- "mtime": "2026-03-08T01:34:02.637Z",
166
+ "mtime": "2026-03-08T06:10:25.333Z",
167
167
  "size": 85068,
168
168
  "path": "../public/assets/inter-latin-ext-wght-normal-DO1Apj_S.woff2"
169
169
  },
170
+ "/assets/inter-latin-wght-normal-Dx4kXJAl.woff2": {
171
+ "type": "font/woff2",
172
+ "etag": '"bc80-8R1ym7Ck2DUNLqPQ/AYs9u8tUpg"',
173
+ "mtime": "2026-03-08T06:10:25.333Z",
174
+ "size": 48256,
175
+ "path": "../public/assets/inter-latin-wght-normal-Dx4kXJAl.woff2"
176
+ },
170
177
  "/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2": {
171
178
  "type": "font/woff2",
172
179
  "etag": '"280c-nBythjoDQ0+5wVAendJ6wU7Xz2M"',
173
- "mtime": "2026-03-08T01:34:02.637Z",
180
+ "mtime": "2026-03-08T06:10:25.333Z",
174
181
  "size": 10252,
175
182
  "path": "../public/assets/inter-vietnamese-wght-normal-CBcvBZtf.woff2"
176
183
  },
177
- "/assets/inter-greek-wght-normal-CkhJZR-_.woff2": {
178
- "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"
184
+ "/assets/styles-CezfLgHY.css": {
185
+ "type": "text/css; charset=utf-8",
186
+ "etag": '"16c03-6spcY0zAbMWYIfx4MkgUIWefXb0"',
187
+ "mtime": "2026-03-08T06:10:25.333Z",
188
+ "size": 93187,
189
+ "path": "../public/assets/styles-CezfLgHY.css"
183
190
  },
184
191
  "/assets/main-DzXOjsqg.js": {
185
192
  "type": "text/javascript; charset=utf-8",
186
193
  "etag": '"59339-tSYXNZ6CNL1Zt0KVnL8TeohfAog"',
187
- "mtime": "2026-03-08T01:34:02.637Z",
194
+ "mtime": "2026-03-08T06:10:25.336Z",
188
195
  "size": 365369,
189
196
  "path": "../public/assets/main-DzXOjsqg.js"
190
197
  },
191
- "/assets/styles-CezfLgHY.css": {
192
- "type": "text/css; charset=utf-8",
193
- "etag": '"16c03-6spcY0zAbMWYIfx4MkgUIWefXb0"',
194
- "mtime": "2026-03-08T01:34:02.637Z",
195
- "size": 93187,
196
- "path": "../public/assets/styles-CezfLgHY.css"
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:10:25.337Z",
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,6 @@
1
1
  {
2
2
  "name": "astro-md-editor",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  ".output/",
11
11
  "index.mjs",
12
12
  "scripts/bootstrap-collections.mjs",
13
- "README.md"
13
+ "README.md",
14
+ "LICENSE.md"
14
15
  ],
15
16
  "imports": {
16
17
  "#/*": "./src/*"