tinymce-inline-comments 0.1.0 → 0.1.1

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 +191 -0
  2. package/package.json +3 -2
package/README.md CHANGED
@@ -0,0 +1,191 @@
1
+ # tinymce-inline-comments
2
+
3
+ A **headless, Google Docs–style inline comments plugin for TinyMCE**.
4
+
5
+ This plugin enables **inline annotations** on selected text and emits
6
+ **comment lifecycle events** (add / select / delete), while keeping
7
+ all **UI, backend APIs, permissions, and threading logic in your app**.
8
+
9
+ Designed for:
10
+
11
+ - Contract editors
12
+ - Legal documents
13
+ - Review & approval workflows
14
+ - Collaborative document tools
15
+
16
+ ---
17
+
18
+ ## Links
19
+
20
+ - **GitHub Repository:**
21
+ https://github.com/chiraagb/tinymce-inline-comments
22
+
23
+ - **Issues & Feature Requests:**
24
+ https://github.com/chiraagb/tinymce-inline-comments/issues
25
+
26
+ ---
27
+
28
+ ## Features
29
+
30
+ - Inline comment annotations using `<span>`
31
+ - Selection-based comments
32
+ - Event-driven (no backend coupling)
33
+ - Annotation delete / unwrap API
34
+ - Framework-agnostic
35
+ - React / Vue / Angular / Vanilla JS friendly
36
+ - Thread-ready architecture
37
+
38
+ ---
39
+
40
+ ## Installation
41
+
42
+ ```bash
43
+ npm install tinymce-inline-comments
44
+ ```
45
+
46
+ ---
47
+
48
+ ## Basic Usage (React Example)
49
+
50
+ ```tsx
51
+ import { Editor } from "@tinymce/tinymce-react";
52
+ import { registerInlineComments } from "tinymce-inline-comments";
53
+
54
+ <Editor
55
+ init={{
56
+ extended_valid_elements: "span[class|data-annotation-id]",
57
+ content_style: `
58
+ .inline-comment {
59
+ background: rgba(145,166,255,0.22);
60
+ border-bottom: 2px solid #6C48C5;
61
+ cursor: pointer;
62
+ }
63
+ .inline-comment.active {
64
+ background: rgba(108,72,197,0.25);
65
+ }
66
+ `,
67
+ setup: (editor) => {
68
+ registerInlineComments(editor);
69
+
70
+ editor.on("inline-comments:add", (e) => {
71
+ console.log("Comment added", e.annotationId, e.selectedText);
72
+ });
73
+
74
+ editor.on("inline-comments:select", (e) => {
75
+ console.log("Comment selected", e.annotationId);
76
+ });
77
+
78
+ editor.on("inline-comments:delete", (e) => {
79
+ console.log("Comment deleted", e.annotationId);
80
+ });
81
+ },
82
+ toolbar: "undo redo | inlineComment",
83
+ }}
84
+ />;
85
+ ```
86
+
87
+ ---
88
+
89
+ ## Events
90
+
91
+ ### `inline-comments:add`
92
+
93
+ Fired when a comment is added to selected text.
94
+
95
+ ```ts
96
+ {
97
+ annotationId: string;
98
+ selectedText: string;
99
+ }
100
+ ```
101
+
102
+ ---
103
+
104
+ ### `inline-comments:select`
105
+
106
+ Fired when an existing annotation is clicked.
107
+
108
+ ```ts
109
+ {
110
+ annotationId: string;
111
+ }
112
+ ```
113
+
114
+ ---
115
+
116
+ ### `inline-comments:delete`
117
+
118
+ Fired when an annotation is removed.
119
+
120
+ ```ts
121
+ {
122
+ annotationId: string;
123
+ }
124
+ ```
125
+
126
+ ---
127
+
128
+ ## API
129
+
130
+ ### `editor.removeInlineComment(annotationId: string)`
131
+
132
+ Removes the inline annotation wrapper while **preserving the text content**.
133
+
134
+ ```ts
135
+ editor.removeInlineComment(annotationId);
136
+ ```
137
+
138
+ ---
139
+
140
+ ## Architecture (Important)
141
+
142
+ This plugin is intentionally **headless**.
143
+
144
+ | Concern | Where it lives |
145
+ | -------------------- | -------------- |
146
+ | UI (sidebar, modals) | Your app |
147
+ | Backend APIs | Your app |
148
+ | Auth & permissions | Your app |
149
+ | Mentions | Your app |
150
+ | Threaded comments | Your app |
151
+ | Inline annotations | This plugin |
152
+
153
+ This design makes the plugin:
154
+
155
+ - Enterprise-safe
156
+ - Highly reusable
157
+ - Easy to extend
158
+
159
+ ---
160
+
161
+ ## Threaded Comments (Recommended Pattern)
162
+
163
+ Use `annotationId` as the thread key:
164
+
165
+ ```json
166
+ {
167
+ "annotation_id": "uuid",
168
+ "thread": [
169
+ { "id": "c1", "text": "Initial comment" },
170
+ { "id": "c2", "text": "Reply" }
171
+ ]
172
+ }
173
+ ```
174
+
175
+ The plugin does **not** enforce a data model.
176
+
177
+ ---
178
+
179
+ ## Notes
180
+
181
+ - The plugin does **not** store comments
182
+ - The plugin does **not** make API calls
183
+ - The plugin does **not** manage UI state
184
+
185
+ This is by design.
186
+
187
+ ---
188
+
189
+ ## License
190
+
191
+ MIT © Chirag Bhandakkar
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tinymce-inline-comments",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Headless inline comments plugin for TinyMCE",
5
5
  "main": "dist/inline-comments.umd.js",
6
6
  "module": "dist/inline-comments.es.js",
@@ -19,6 +19,7 @@
19
19
  "build": "vite build"
20
20
  },
21
21
  "devDependencies": {
22
- "tinymce": "^8.3.1"
22
+ "tinymce": "^8.3.1",
23
+ "vite": "^7.3.0"
23
24
  }
24
25
  }