@toantranmei/comments 0.0.0-stage → 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.
- package/LICENSE +21 -0
- package/README.md +113 -2
- package/dist/index.js +895 -0
- package/dist/index.js.map +1 -0
- package/dist/style.css +2 -0
- package/dist/types/CommentComposer.vue.d.ts +28 -0
- package/dist/types/CommentItem.vue.d.ts +13 -0
- package/dist/types/CommentsGutter.vue.d.ts +20 -0
- package/dist/types/CommentsPanel.vue.d.ts +24 -0
- package/dist/types/ThreadCard.vue.d.ts +20 -0
- package/dist/types/anchor.d.ts +47 -0
- package/dist/types/definition.d.ts +8 -0
- package/dist/types/extension.d.ts +42 -0
- package/dist/types/format.d.ts +9 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/messages.d.ts +36 -0
- package/dist/types/store.d.ts +23 -0
- package/dist/types/types.d.ts +90 -0
- package/package.json +80 -3
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import type { JSONContent, LocaleName } from '@toantranmei/editor';
|
|
2
|
+
import type { Ref } from 'vue';
|
|
3
|
+
import type { CommentsMessages } from './messages';
|
|
4
|
+
/** What a thread is attached to (contract 2.4). Block ids are the editor's `data-id`. */
|
|
5
|
+
export type Anchor = {
|
|
6
|
+
kind: 'page';
|
|
7
|
+
} | {
|
|
8
|
+
kind: 'block';
|
|
9
|
+
block_id: string;
|
|
10
|
+
} | {
|
|
11
|
+
kind: 'text';
|
|
12
|
+
block_id: string;
|
|
13
|
+
quote: string;
|
|
14
|
+
};
|
|
15
|
+
export interface CommentAuthor {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
avatar_url?: string | null;
|
|
19
|
+
}
|
|
20
|
+
export interface Comment {
|
|
21
|
+
id: string;
|
|
22
|
+
author: CommentAuthor;
|
|
23
|
+
/** Small ProseMirror document (paragraphs, text, `mention` nodes). */
|
|
24
|
+
body: JSONContent;
|
|
25
|
+
/** RFC 3339. */
|
|
26
|
+
created_at: string;
|
|
27
|
+
edited_at?: string | null;
|
|
28
|
+
}
|
|
29
|
+
export interface Thread {
|
|
30
|
+
id: string;
|
|
31
|
+
anchor: Anchor;
|
|
32
|
+
/** RFC 3339 when resolved, else null. */
|
|
33
|
+
resolved_at: string | null;
|
|
34
|
+
/** Oldest first; the first comment opens the thread. */
|
|
35
|
+
comments: Comment[];
|
|
36
|
+
}
|
|
37
|
+
/** Signed-in user. */
|
|
38
|
+
export interface CommentsUser {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
avatar?: string | null;
|
|
42
|
+
}
|
|
43
|
+
/** Someone to @mention in a comment. */
|
|
44
|
+
export interface Person {
|
|
45
|
+
id: string;
|
|
46
|
+
name: string;
|
|
47
|
+
avatar?: string | null;
|
|
48
|
+
/** Secondary line in the picker (email…). */
|
|
49
|
+
description?: string;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Your backend, behind one adapter. `threads` is the live list for the current page
|
|
53
|
+
* (load it with `GET /resources/{id}/comments`, keep it fresh on sync events); the
|
|
54
|
+
* methods call the API and update `threads` themselves (optimistically or after the response).
|
|
55
|
+
*/
|
|
56
|
+
export interface CommentsSource {
|
|
57
|
+
me: Ref<CommentsUser | null>;
|
|
58
|
+
threads: Ref<Thread[]>;
|
|
59
|
+
create: (anchor: Anchor, body: JSONContent) => Promise<Thread>;
|
|
60
|
+
reply: (threadId: string, body: JSONContent) => Promise<Comment>;
|
|
61
|
+
edit: (commentId: string, body: JSONContent) => Promise<void | Comment>;
|
|
62
|
+
remove: (commentId: string) => Promise<void>;
|
|
63
|
+
resolve: (threadId: string, resolved: boolean) => Promise<void | Thread>;
|
|
64
|
+
/** People for @mentions in comment bodies. */
|
|
65
|
+
people: (query: string) => Person[] | Promise<Person[]>;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Access on the page (contract 2.1 levels): `view` sees comments; `comment` adds and
|
|
69
|
+
* replies without editing text (anchors by block id + quote); `edit` / `full` also mark
|
|
70
|
+
* the commented text in the document (`comment` mark, synced in collaboration mode).
|
|
71
|
+
*/
|
|
72
|
+
export type CommentsLevel = 'view' | 'comment' | 'edit' | 'full';
|
|
73
|
+
export interface CommentsOptions {
|
|
74
|
+
source: CommentsSource | null;
|
|
75
|
+
/** Default `'edit'`. A ref or getter follows changes. */
|
|
76
|
+
level: CommentsLevel | Ref<CommentsLevel> | (() => CommentsLevel);
|
|
77
|
+
/** Called when the bubble-menu "Comment" starts a draft (e.g. open your side panel). */
|
|
78
|
+
onCompose: ((draft: CommentDraft) => void) | null;
|
|
79
|
+
/** Called when a highlight or gutter badge is clicked. */
|
|
80
|
+
onOpenThread: ((threadId: string) => void) | null;
|
|
81
|
+
/** Override strings: `{ en: { comment: 'Add comment' } }`. */
|
|
82
|
+
messages: Partial<Record<LocaleName, Partial<CommentsMessages>>> | null;
|
|
83
|
+
}
|
|
84
|
+
/** A comment being written for a text selection (not saved yet). */
|
|
85
|
+
export interface CommentDraft {
|
|
86
|
+
anchor: Anchor;
|
|
87
|
+
/** Document range of the selection at draft time (kept mapped while it's open). */
|
|
88
|
+
from: number;
|
|
89
|
+
to: number;
|
|
90
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@toantranmei/comments",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Notion-style comments (marks, gutter badges, side panel, threads) for @toantranmei/editor.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"vue",
|
|
7
|
+
"tiptap",
|
|
8
|
+
"notion",
|
|
9
|
+
"comments",
|
|
10
|
+
"editor",
|
|
11
|
+
"collaboration"
|
|
12
|
+
],
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "toantranmei",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "git+https://github.com/toantranmei/editor.git",
|
|
18
|
+
"directory": "packages/comments"
|
|
19
|
+
},
|
|
20
|
+
"homepage": "https://github.com/toantranmei/editor#readme",
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/toantranmei/editor/issues"
|
|
23
|
+
},
|
|
24
|
+
"type": "module",
|
|
25
|
+
"files": [
|
|
26
|
+
"dist",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
30
|
+
"main": "./dist/index.js",
|
|
31
|
+
"module": "./dist/index.js",
|
|
32
|
+
"types": "./dist/types/index.d.ts",
|
|
33
|
+
"exports": {
|
|
34
|
+
".": {
|
|
35
|
+
"types": "./dist/types/index.d.ts",
|
|
36
|
+
"import": "./dist/index.js"
|
|
37
|
+
},
|
|
38
|
+
"./style.css": "./dist/style.css"
|
|
39
|
+
},
|
|
40
|
+
"sideEffects": [
|
|
41
|
+
"**/*.css"
|
|
42
|
+
],
|
|
43
|
+
"peerDependencies": {
|
|
44
|
+
"@lucide/vue": "^1.61.0",
|
|
45
|
+
"@tiptap/core": "3.32.0",
|
|
46
|
+
"@tiptap/pm": "3.32.0",
|
|
47
|
+
"@tiptap/starter-kit": "3.32.0",
|
|
48
|
+
"@tiptap/vue-3": "3.32.0",
|
|
49
|
+
"@toantranmei/editor": "^0.3.0",
|
|
50
|
+
"vue": "^3.5.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@lucide/vue": "^1.61.0",
|
|
54
|
+
"@tiptap/core": "3.32.0",
|
|
55
|
+
"@tiptap/pm": "3.32.0",
|
|
56
|
+
"@tiptap/starter-kit": "3.32.0",
|
|
57
|
+
"@tiptap/vue-3": "3.32.0",
|
|
58
|
+
"@types/node": "^26.6.5",
|
|
59
|
+
"@vitejs/plugin-vue": "^6.0.10",
|
|
60
|
+
"@vue/test-utils": "^2.4.6",
|
|
61
|
+
"happy-dom": "21.0.4",
|
|
62
|
+
"typescript": "~5.9.3",
|
|
63
|
+
"vite": "^8.3.5",
|
|
64
|
+
"vitest": "5.0.5",
|
|
65
|
+
"vue": "^3.5.0",
|
|
66
|
+
"vue-tsc": "^3.0.0",
|
|
67
|
+
"yjs": "^13.6.0",
|
|
68
|
+
"@toantranmei/editor": "0.3.0"
|
|
69
|
+
},
|
|
70
|
+
"publishConfig": {
|
|
71
|
+
"access": "public"
|
|
72
|
+
},
|
|
73
|
+
"engines": {
|
|
74
|
+
"node": ">=20"
|
|
75
|
+
},
|
|
76
|
+
"scripts": {
|
|
77
|
+
"build": "node ../editor/scripts/check-styles.mjs src && vite build && vue-tsc -p tsconfig.build.json",
|
|
78
|
+
"dev": "vite build --watch",
|
|
79
|
+
"typecheck": "vue-tsc --noEmit -p tsconfig.json",
|
|
80
|
+
"check:styles": "node ../editor/scripts/check-styles.mjs src",
|
|
81
|
+
"test": "vitest run"
|
|
82
|
+
}
|
|
6
83
|
}
|