@datawhale/prosemirror-render 0.0.14 → 0.0.17

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.
Files changed (2) hide show
  1. package/README.md +112 -0
  2. package/package.json +5 -2
package/README.md ADDED
@@ -0,0 +1,112 @@
1
+ # @datawhale/prosemirror-render
2
+
3
+ 将 ProseMirror / Tiptap 的 JSON 文档(`PMNode`)渲染为 Vue 3 组件的只读渲染库。
4
+
5
+ ## 安装
6
+
7
+ ```bash
8
+ npm install @datawhale/prosemirror-render
9
+ ```
10
+
11
+ ## 使用
12
+
13
+ ```ts
14
+ import { TreeRender, Media } from "@datawhale/prosemirror-render";
15
+ ```
16
+
17
+ ```vue
18
+ <TreeRender :node="docJson" :axios="httpClient" />
19
+ ```
20
+
21
+ - `node`:ProseMirror 文档节点(`{ type: "doc", content: [...] }`)。
22
+ - `axios`:满足 `HTTPClientType` 接口的 HTTP 客户端,仅在附件 / 视频分析等场景使用,普通文档渲染可传空实现。
23
+
24
+ ## 本地预览 / 调试
25
+
26
+ 不需要发布即可在浏览器里渲染任意本地 JSON:
27
+
28
+ ```bash
29
+ npm run dev
30
+ ```
31
+
32
+ 打开终端里打印的地址后,可以:
33
+
34
+ - 点 **选择 JSON 文件** 从磁盘选一个 `.json`;
35
+ - 直接把 `.json` **拖拽**到画布上;
36
+ - 把 JSON 文件放进 [`dev/samples/`](dev/samples/),会自动出现在 **内置样例** 下拉里(支持热更新,改文件即刷新)。
37
+
38
+ JSON 可以是裸的 doc 节点 `{ "type": "doc", ... }`,也可以是 `{ "doc": {...} }` 包装形式,会自动识别。
39
+
40
+ 相关文件:`index.html`、`dev/main.ts`、`dev/DevApp.vue`。
41
+
42
+ ## 发布流程
43
+
44
+ 发布只包含 `dist`(见 package.json 的 `"files": ["dist"]`),需要先构建。
45
+
46
+ ### 一次性发布(推荐)
47
+
48
+ ```bash
49
+ npm run release
50
+ ```
51
+
52
+ 它等价于依次执行 `npm run bump` + `npm publish --access public`(见下面拆解)。
53
+
54
+ ### 分步执行
55
+
56
+ 1. **确保工作区干净**(`npm version` 会拒绝有未提交的已跟踪改动):
57
+
58
+ ```bash
59
+ git status # 应为 clean,否则先 commit / stash
60
+ ```
61
+
62
+ 2. **构建 + 升版本 + 打 tag**:
63
+
64
+ ```bash
65
+ npm run bump
66
+ ```
67
+
68
+ `bump` 做了三件事:
69
+
70
+ - `npm run build`:`vite build` 打包 + `vue-tsc` 生成类型到 `dist/`;
71
+ - `npm version patch`:把 `package.json` 的版本号 `+1`(如 `0.0.15 → 0.0.16`),
72
+ 并**自动生成一个 commit 和 tag**:
73
+ - commit message:`release: v0.0.16`
74
+ - git tag:`v0.0.16`
75
+ - `postversion` 钩子:`git push --follow-tags`,把这个 commit 和 tag **一起推到 GitHub**(`origin`)。
76
+
77
+ 3. **发布到 npm**:
78
+
79
+ ```bash
80
+ npm publish --access public
81
+ ```
82
+
83
+ > `@datawhale` 是 scoped 包,默认私有,必须带 `--access public` 才能公开发布。
84
+
85
+ ### 发布前的一次性准备
86
+
87
+ - **登录 npm**,且账号有 `@datawhale` 组织的发布权限:
88
+
89
+ ```bash
90
+ npm whoami # 确认已登录
91
+ npm login # 未登录时执行
92
+ ```
93
+
94
+ - **GitHub 推送权限**:`bump` 会自动 `git push`,需保证本地在 `main` 分支且对 `origin`
95
+ (`github.com/GYHHAHA/prosemirror-render`)有推送权限。
96
+
97
+ ### 版本号规则
98
+
99
+ `npm version patch` 只递增补丁号。如需改次版本 / 主版本,手动指定:
100
+
101
+ ```bash
102
+ npm run build && npm version minor -m "release: v%s" # 0.0.x → 0.1.0
103
+ npm run build && npm version major -m "release: v%s" # 0.x.x → 1.0.0
104
+ ```
105
+
106
+ ### (可选)创建 GitHub Release
107
+
108
+ `bump` 只打 git tag。若想在 GitHub 上生成正式的 Release 页面,安装 [`gh`](https://cli.github.com/) 后:
109
+
110
+ ```bash
111
+ gh release create v0.0.16 --generate-notes
112
+ ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datawhale/prosemirror-render",
3
- "version": "0.0.14",
3
+ "version": "0.0.17",
4
4
  "type": "module",
5
5
  "main": "./dist/index.cjs.js",
6
6
  "module": "./dist/index.es.js",
@@ -9,8 +9,11 @@
9
9
  "dist"
10
10
  ],
11
11
  "scripts": {
12
+ "dev": "vite",
12
13
  "build": "vite build && vue-tsc -p tsconfig.build.json",
13
- "bump": "npm run build && npm version patch --no-git-tag-version"
14
+ "bump": "npm run build && npm version patch -m \"release: v%s\"",
15
+ "postversion": "git push --follow-tags",
16
+ "release": "npm run bump && npm publish --access public"
14
17
  },
15
18
  "keywords": [],
16
19
  "author": "",