tinymce-inline-comments 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 ADDED
@@ -0,0 +1,2 @@
1
+ MIT License
2
+ Copyright (c) 2025 Chirag Bhandakkar
package/README.md ADDED
File without changes
@@ -0,0 +1,46 @@
1
+ function c(n) {
2
+ const s = "inline_comment", o = "inline-comment";
3
+ n.on("init", () => {
4
+ n.formatter.register(s, {
5
+ inline: "span",
6
+ classes: o,
7
+ attributes: { "data-annotation-id": "%value" }
8
+ });
9
+ }), n.addCommand("inline-comments:add", () => {
10
+ if (n.selection.isCollapsed()) return;
11
+ const t = crypto.randomUUID(), a = n.selection.getContent({ format: "text" });
12
+ n.undoManager.transact(() => {
13
+ n.formatter.apply(s, { value: t });
14
+ }), n.fire("inline-comments:add", { annotationId: t, selectedText: a });
15
+ }), n.removeInlineComment = (t) => {
16
+ n.undoManager.transact(() => {
17
+ n.dom.select(
18
+ `span[data-annotation-id="${t}"]`
19
+ ).forEach((e) => {
20
+ const i = e.parentNode;
21
+ if (i) {
22
+ for (; e.firstChild; )
23
+ i.insertBefore(e.firstChild, e);
24
+ i.removeChild(e);
25
+ }
26
+ });
27
+ }), n.fire("inline-comments:delete", { annotationId: t });
28
+ }, n.on("click", (t) => {
29
+ const a = n.dom.getParent(t.target, `span.${o}`);
30
+ if (!a) return;
31
+ const e = a.getAttribute("data-annotation-id");
32
+ e && (n.dom.select(`.${o}`).forEach((i) => i.classList.remove("active")), a.classList.add("active"), n.fire("inline-comments:select", { annotationId: e }));
33
+ }), n.ui.registry.addButton("inlineComment", {
34
+ icon: "comment",
35
+ tooltip: "Add comment",
36
+ onAction: () => n.execCommand("inline-comments:add")
37
+ }), n.ui.registry.addContextToolbar("inlineCommentToolbar", {
38
+ predicate: () => !n.selection.isCollapsed(),
39
+ items: "inlineComment",
40
+ position: "selection",
41
+ scope: "editor"
42
+ });
43
+ }
44
+ export {
45
+ c as registerInlineComments
46
+ };
@@ -0,0 +1 @@
1
+ (function(i,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(i=typeof globalThis<"u"?globalThis:i||self,s(i.TinymceInlineComments={}))})(this,(function(i){"use strict";function s(e){const c="inline_comment",m="inline-comment";e.on("init",()=>{e.formatter.register(c,{inline:"span",classes:m,attributes:{"data-annotation-id":"%value"}})}),e.addCommand("inline-comments:add",()=>{if(e.selection.isCollapsed())return;const t=crypto.randomUUID(),o=e.selection.getContent({format:"text"});e.undoManager.transact(()=>{e.formatter.apply(c,{value:t})}),e.fire("inline-comments:add",{annotationId:t,selectedText:o})}),e.removeInlineComment=t=>{e.undoManager.transact(()=>{e.dom.select(`span[data-annotation-id="${t}"]`).forEach(n=>{const a=n.parentNode;if(a){for(;n.firstChild;)a.insertBefore(n.firstChild,n);a.removeChild(n)}})}),e.fire("inline-comments:delete",{annotationId:t})},e.on("click",t=>{const o=e.dom.getParent(t.target,`span.${m}`);if(!o)return;const n=o.getAttribute("data-annotation-id");n&&(e.dom.select(`.${m}`).forEach(a=>a.classList.remove("active")),o.classList.add("active"),e.fire("inline-comments:select",{annotationId:n}))}),e.ui.registry.addButton("inlineComment",{icon:"comment",tooltip:"Add comment",onAction:()=>e.execCommand("inline-comments:add")}),e.ui.registry.addContextToolbar("inlineCommentToolbar",{predicate:()=>!e.selection.isCollapsed(),items:"inlineComment",position:"selection",scope:"editor"})}i.registerInlineComments=s,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})}));
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "tinymce-inline-comments",
3
+ "version": "0.1.0",
4
+ "description": "Headless inline comments plugin for TinyMCE",
5
+ "main": "dist/inline-comments.umd.js",
6
+ "module": "dist/inline-comments.es.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
11
+ "license": "MIT",
12
+ "author": "Chirag Bhandakkar",
13
+ "keywords": [
14
+ "tinymce",
15
+ "comments",
16
+ "annotations"
17
+ ],
18
+ "scripts": {
19
+ "build": "vite build"
20
+ },
21
+ "devDependencies": {
22
+ "tinymce": "^8.3.1"
23
+ }
24
+ }