tiptap-markdown-react 0.1.0

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.
@@ -0,0 +1,31 @@
1
+ /**
2
+ * 最小 Tiptap JSON 节点结构(只取本模块用到的字段)。
3
+ * 不从 `@tiptap/core` 引 `JSONContent`——core 是嵌套依赖、非直接依赖,
4
+ * 直接 import 类型解析不到(与仓库既有做法一致,见 extensions.ts)。
5
+ */
6
+ interface TocDocNode {
7
+ type?: string;
8
+ text?: string;
9
+ attrs?: Record<string, unknown> | null;
10
+ content?: TocDocNode[];
11
+ }
12
+ /** 目录项。 */
13
+ export interface TocItem {
14
+ /** 锚点 id(= heading 的 data-toc-id / id,由 generateTocIds 注入)。 */
15
+ id: string;
16
+ /** 标题层级(1-6)。 */
17
+ level: number;
18
+ /** 标题纯文本。 */
19
+ text: string;
20
+ /** 付费墙锁住的章节(置灰不可点)。 */
21
+ locked?: boolean;
22
+ }
23
+ /**
24
+ * 从已注入锚点 id 的 Tiptap JSON doc 提取 h1-h6 目录。
25
+ *
26
+ * 必须在 `generateTocIds` 之后调用(heading 的 attrs 里才有 `data-toc-id`)。
27
+ * `lockedTitles`:被截断(锁住)章节标题,命中则标 `locked`——
28
+ * 目录列全部章节,锁住项置灰不可点(付费墙钩子)。用 Set 便于去重命中。
29
+ */
30
+ export declare function extractToc(doc: TocDocNode, lockedTitles?: string[]): TocItem[];
31
+ export {};
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 目录锚点 id 生成——阅读页(SSR)与编辑页(editor)共用的**单一真源**,
3
+ * 保证「创作预览的锚点 = 发布后阅读页的锚点」。
4
+ *
5
+ * 用 slug 而非官方默认 UUID:slug 跨 SSR / ISR revalidate 稳定(UUID 每次都变、
6
+ * 分享的 #hash 会失效),且 `#introduction` 比 `#d4590f81-…` 可读、对 SEO 友好。
7
+ *
8
+ * slug 会重名(两个「细节」都 slug 成 `xi-jie`),故用闭包计数器去重:
9
+ * 同名追加 -2 / -3(已实测:details / details-2 / details-3,HTML id 全唯一)。
10
+ */
11
+ /**
12
+ * 造一个带去重的 `getId`。每次生成新实例(闭包各自计数),传给
13
+ * `TableOfContents.configure({ getId })` 或 `generateTocIds` 的扩展配置。
14
+ */
15
+ export declare function makeTocGetId(): (content: string) => string;
package/package.json ADDED
@@ -0,0 +1,110 @@
1
+ {
2
+ "name": "tiptap-markdown-react",
3
+ "version": "0.1.0",
4
+ "description": "A batteries-included, self-styled Markdown WYSIWYG editor and reader suite built on Tiptap v3. Markdown in/out, SSR/static rendering, table of contents, themeable via CSS variables, zero Ant Design.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "author": "CatsInJune",
8
+ "homepage": "https://github.com/CatsInJune/tiptap-markdown-react#readme",
9
+ "bugs": {
10
+ "url": "https://github.com/CatsInJune/tiptap-markdown-react/issues"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/CatsInJune/tiptap-markdown-react.git"
15
+ },
16
+ "keywords": [
17
+ "tiptap",
18
+ "markdown",
19
+ "editor",
20
+ "wysiwyg",
21
+ "rich-text",
22
+ "react",
23
+ "prosemirror",
24
+ "ssr",
25
+ "table-of-contents"
26
+ ],
27
+ "sideEffects": [
28
+ "**/*.css"
29
+ ],
30
+ "files": [
31
+ "dist"
32
+ ],
33
+ "main": "./dist/index.js",
34
+ "module": "./dist/index.js",
35
+ "types": "./dist/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./dist/index.d.ts",
39
+ "import": "./dist/index.js"
40
+ },
41
+ "./server": {
42
+ "types": "./dist/server.d.ts",
43
+ "import": "./dist/server.js"
44
+ },
45
+ "./style.css": "./dist/style.css"
46
+ },
47
+ "scripts": {
48
+ "build": "vite build",
49
+ "dev": "vite build --watch",
50
+ "typecheck": "tsc --noEmit",
51
+ "prepublishOnly": "npm run build"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public"
55
+ },
56
+ "peerDependencies": {
57
+ "@tiptap/extension-code-block-lowlight": "^3.27.0",
58
+ "@tiptap/extension-highlight": "^3.27.0",
59
+ "@tiptap/extension-image": "^3.27.0",
60
+ "@tiptap/extension-subscript": "^3.27.0",
61
+ "@tiptap/extension-superscript": "^3.27.0",
62
+ "@tiptap/extension-table": "^3.27.0",
63
+ "@tiptap/extension-table-of-contents": "^3.27.0",
64
+ "@tiptap/extension-task-item": "^3.27.0",
65
+ "@tiptap/extension-task-list": "^3.27.0",
66
+ "@tiptap/extension-text-style": "^3.27.0",
67
+ "@tiptap/markdown": "^3.27.0",
68
+ "@tiptap/pm": "^3.27.0",
69
+ "@tiptap/react": "^3.27.0",
70
+ "@tiptap/starter-kit": "^3.27.0",
71
+ "@tiptap/static-renderer": "^3.27.0",
72
+ "lowlight": "^3.0.0",
73
+ "react": ">=18.0.0",
74
+ "react-dom": ">=18.0.0"
75
+ },
76
+ "dependencies": {
77
+ "@radix-ui/react-dropdown-menu": "^2.1.16",
78
+ "@radix-ui/react-popover": "^1.1.15"
79
+ },
80
+ "devDependencies": {
81
+ "@tiptap/extension-code-block-lowlight": "^3.27.1",
82
+ "@tiptap/extension-highlight": "^3.27.1",
83
+ "@tiptap/extension-image": "^3.27.1",
84
+ "@tiptap/extension-subscript": "^3.27.1",
85
+ "@tiptap/extension-superscript": "^3.27.1",
86
+ "@tiptap/extension-table": "^3.27.1",
87
+ "@tiptap/extension-table-of-contents": "^3.27.1",
88
+ "@tiptap/extension-task-item": "^3.27.1",
89
+ "@tiptap/extension-task-list": "^3.27.1",
90
+ "@tiptap/extension-text-style": "^3.27.1",
91
+ "@tiptap/markdown": "^3.27.1",
92
+ "@tiptap/pm": "^3.27.1",
93
+ "@tiptap/react": "^3.27.1",
94
+ "@tiptap/starter-kit": "^3.27.1",
95
+ "@tiptap/static-renderer": "^3.27.1",
96
+ "@types/react": "^19.2.17",
97
+ "@types/react-dom": "^19.2.3",
98
+ "@vitejs/plugin-react": "^4.7.0",
99
+ "lowlight": "^3.3.0",
100
+ "react": "^19.2.7",
101
+ "react-dom": "^19.2.7",
102
+ "rollup-preserve-directives": "^1.1.3",
103
+ "typescript": "^5.9.3",
104
+ "vite": "^5.4.21",
105
+ "vite-plugin-dts": "^4.5.4"
106
+ },
107
+ "overrides": {
108
+ "@tiptap/core": "3.27.3"
109
+ }
110
+ }