@pixerate/editor 0.2.3 → 0.3.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.
@@ -21,6 +21,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var serializers_exports = {};
22
22
  __export(serializers_exports, {
23
23
  escapeHtml: () => escapeHtml,
24
+ extractMentionsFromDoc: () => extractMentionsFromDoc,
24
25
  getEditorText: () => getEditorText,
25
26
  htmlToPlainText: () => htmlToPlainText,
26
27
  plainTextToTipTapHtml: () => plainTextToTipTapHtml
@@ -41,9 +42,16 @@ function plainTextToTipTapHtml(text) {
41
42
  }
42
43
  function htmlToPlainText(html) {
43
44
  if (!html) return "";
45
+ const mentionNormalized = html.replace(
46
+ /<span[^>]*data-type=["']mention["'][^>]*data-label=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
47
+ "@$1"
48
+ ).replace(
49
+ /<span[^>]*data-type=["']mention["'][^>]*data-id=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
50
+ "@$1"
51
+ );
44
52
  if (typeof document !== "undefined") {
45
53
  const tempDiv = document.createElement("div");
46
- tempDiv.innerHTML = html;
54
+ tempDiv.innerHTML = mentionNormalized;
47
55
  tempDiv.querySelectorAll("br.ProseMirror-trailingBreak").forEach((br) => br.remove());
48
56
  tempDiv.querySelectorAll("br").forEach((br) => br.replaceWith("\n"));
49
57
  const paragraphs = tempDiv.querySelectorAll("p, div, li, h1, h2, h3, h4, h5, h6");
@@ -56,7 +64,7 @@ function htmlToPlainText(html) {
56
64
  }
57
65
  return tempDiv.textContent || "";
58
66
  }
59
- return html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
67
+ return mentionNormalized.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
60
68
  }
61
69
  function getEditorText(editor) {
62
70
  if (!editor) return "";
@@ -73,9 +81,84 @@ function getEditorText(editor) {
73
81
  }
74
82
  return "";
75
83
  }
84
+ function extractMentionsFromDoc(docOrEditor) {
85
+ if (!docOrEditor) return [];
86
+ const mentions = [];
87
+ const doc = docOrEditor?.state?.doc || (typeof docOrEditor?.descendants === "function" ? docOrEditor : null);
88
+ if (doc && typeof doc.descendants === "function") {
89
+ doc.descendants((node) => {
90
+ if (node.type?.name === "mention" && node.attrs) {
91
+ mentions.push({
92
+ id: node.attrs.id || "",
93
+ label: node.attrs.label || "",
94
+ type: node.attrs.type,
95
+ avatarUrl: node.attrs.avatarUrl,
96
+ color: node.attrs.color,
97
+ ...node.attrs
98
+ });
99
+ }
100
+ });
101
+ return mentions;
102
+ }
103
+ if (typeof docOrEditor === "object" && docOrEditor.content) {
104
+ const walk = (nodes) => {
105
+ for (const node of nodes) {
106
+ if (node.type === "mention" && node.attrs) {
107
+ mentions.push({
108
+ id: node.attrs.id || "",
109
+ label: node.attrs.label || "",
110
+ type: node.attrs.type,
111
+ avatarUrl: node.attrs.avatarUrl,
112
+ color: node.attrs.color,
113
+ ...node.attrs
114
+ });
115
+ }
116
+ if (Array.isArray(node.content)) {
117
+ walk(node.content);
118
+ }
119
+ }
120
+ };
121
+ walk(docOrEditor.content);
122
+ return mentions;
123
+ }
124
+ if (typeof docOrEditor === "string") {
125
+ if (typeof document !== "undefined") {
126
+ const div = document.createElement("div");
127
+ div.innerHTML = docOrEditor;
128
+ div.querySelectorAll('span[data-type="mention"]').forEach((el) => {
129
+ mentions.push({
130
+ id: el.getAttribute("data-id") || "",
131
+ label: el.getAttribute("data-label") || "",
132
+ type: el.getAttribute("data-type-name") || void 0,
133
+ avatarUrl: el.getAttribute("data-avatar-url") || void 0,
134
+ color: el.getAttribute("data-color") || void 0
135
+ });
136
+ });
137
+ } else {
138
+ const spanRegex = /<span([^>]*data-type=["']mention["'][^>]*)>/gi;
139
+ let match;
140
+ while ((match = spanRegex.exec(docOrEditor)) !== null) {
141
+ const attrStr = match[1];
142
+ const getAttr = (name) => {
143
+ const m = new RegExp(`${name}=["']([^"']*)["']`, "i").exec(attrStr);
144
+ return m ? m[1] : void 0;
145
+ };
146
+ mentions.push({
147
+ id: getAttr("data-id") || "",
148
+ label: getAttr("data-label") || "",
149
+ type: getAttr("data-type-name") || getAttr("data-entity-type"),
150
+ avatarUrl: getAttr("data-avatar-url"),
151
+ color: getAttr("data-color")
152
+ });
153
+ }
154
+ }
155
+ }
156
+ return mentions;
157
+ }
76
158
  // Annotate the CommonJS export names for ESM import in node:
77
159
  0 && (module.exports = {
78
160
  escapeHtml,
161
+ extractMentionsFromDoc,
79
162
  getEditorText,
80
163
  htmlToPlainText,
81
164
  plainTextToTipTapHtml
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/serializers/index.ts","../../src/serializers/plain-text.ts"],"sourcesContent":["export * from \"./plain-text\";\n","/**\n * Escapes characters that have syntactic meaning in HTML text.\n */\nexport function escapeHtml(text: string): string {\n if (!text) return \"\";\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n}\n\n/**\n * Converts a plain-text string with newlines into HTML paragraphs suitable\n * for TipTap initial content or setContent, preserving line breaks.\n */\nexport function plainTextToTipTapHtml(text: string): string {\n if (!text) return \"<p></p>\";\n if (/<p[\\s>]/i.test(text)) {\n return text;\n }\n return text\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\r/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => `<p>${escapeHtml(line)}</p>`)\n .join(\"\");\n}\n\n/**\n * Extracts plain text from an HTML string or TipTap HTML, preserving newlines between block tags.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n if (typeof document !== \"undefined\") {\n const tempDiv = document.createElement(\"div\");\n tempDiv.innerHTML = html;\n tempDiv\n .querySelectorAll(\"br.ProseMirror-trailingBreak\")\n .forEach((br) => br.remove());\n tempDiv.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n const paragraphs = tempDiv.querySelectorAll(\"p, div, li, h1, h2, h3, h4, h5, h6\");\n if (paragraphs.length > 0) {\n const textParts: string[] = [];\n paragraphs.forEach((p) => {\n textParts.push(p.textContent || \"\");\n });\n return textParts.join(\"\\n\");\n }\n return tempDiv.textContent || \"\";\n }\n\n // Node.js fallback regex\n return html\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/p>/gi, \"\\n\")\n .replace(/<\\/div>/gi, \"\\n\")\n .replace(/<\\/li>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#039;/g, \"'\")\n .trim();\n}\n\n/**\n * Extracts plain text from a TipTap editor instance, preserving newline separators\n * between block nodes.\n */\nexport function getEditorText(editor: any): string {\n if (!editor) return \"\";\n const html = typeof editor.getHTML === \"function\" ? editor.getHTML() : \"\";\n if (html) {\n return htmlToPlainText(html);\n }\n if (typeof editor.getText === \"function\") {\n try {\n return editor.getText({ blockSeparator: \"\\n\" });\n } catch {\n return editor.getText();\n }\n }\n return \"\";\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,SAAS,WAAW,MAAsB;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM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AAqB;AACjD,MAAI,CAAC,OAAQ,QAAO;AACpB,QAAM,OAAO,OAAO,OAAO,YAAY,aAAa,OAAO,QAAQ,IAAI;AACvE,MAAI,MAAM;AACR,WAAO,gBAAgB,IAAI;AAAA,EAC7B;AACA,MAAI,OAAO,OAAO,YAAY,YAAY;AACxC,QAAI;AACF,aAAO,OAAO,QAAQ,EAAE,gBAAgB,KAAK,CAAC;AAAA,IAChD,QAAQ;AACN,aAAO,OAAO,QAAQ;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/serializers/index.ts","../../src/serializers/plain-text.ts"],"sourcesContent":["export * from \"./plain-text\";\n","/**\n * Escapes characters that have syntactic meaning in HTML text.\n */\nexport function escapeHtml(text: string): string {\n if (!text) return \"\";\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n}\n\n/**\n * Converts a plain-text string with newlines into HTML paragraphs suitable\n * for TipTap initial content or setContent, preserving line breaks.\n */\nexport function plainTextToTipTapHtml(text: string): string {\n if (!text) return \"<p></p>\";\n if (/<p[\\s>]/i.test(text)) {\n return text;\n }\n return text\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\r/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => `<p>${escapeHtml(line)}</p>`)\n .join(\"\");\n}\n\n/**\n * Extracts plain text from an HTML string or TipTap HTML, preserving newlines between block tags.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n\n // Normalize mentions so data-label is preserved as @label even if textContent is empty\n const mentionNormalized = html\n .replace(\n /<span[^>]*data-type=[\"']mention[\"'][^>]*data-label=[\"']([^\"']+)[\"'][^>]*>.*?<\\/span>/gi,\n \"@$1\",\n )\n .replace(\n /<span[^>]*data-type=[\"']mention[\"'][^>]*data-id=[\"']([^\"']+)[\"'][^>]*>.*?<\\/span>/gi,\n \"@$1\",\n );\n\n if (typeof document !== \"undefined\") {\n const tempDiv = document.createElement(\"div\");\n tempDiv.innerHTML = mentionNormalized;\n tempDiv\n .querySelectorAll(\"br.ProseMirror-trailingBreak\")\n .forEach((br) => br.remove());\n tempDiv.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n const paragraphs = tempDiv.querySelectorAll(\"p, div, li, h1, h2, h3, h4, h5, h6\");\n if (paragraphs.length > 0) {\n const textParts: string[] = [];\n paragraphs.forEach((p) => {\n textParts.push(p.textContent || \"\");\n });\n return textParts.join(\"\\n\");\n }\n return tempDiv.textContent || \"\";\n }\n\n // Node.js fallback regex\n return mentionNormalized\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/p>/gi, \"\\n\")\n .replace(/<\\/div>/gi, \"\\n\")\n .replace(/<\\/li>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#039;/g, \"'\")\n .trim();\n}\n\n/**\n * Extracts plain text from a TipTap editor instance, preserving newline separators\n * between block nodes and converting mention nodes to @label.\n */\nexport function getEditorText(editor: any): string {\n if (!editor) return \"\";\n const html = typeof editor.getHTML === \"function\" ? editor.getHTML() : \"\";\n if (html) {\n return htmlToPlainText(html);\n }\n if (typeof editor.getText === \"function\") {\n try {\n return editor.getText({ blockSeparator: \"\\n\" });\n } catch {\n return editor.getText();\n }\n }\n return \"\";\n}\n\nexport interface ExtractedMention {\n id: string;\n label: string;\n type?: string;\n avatarUrl?: string;\n color?: string;\n [key: string]: any;\n}\n\n/**\n * Traverses an editor instance, ProseMirror document, JSONContent, or HTML string\n * and extracts all mention attributes without needing regex.\n */\nexport function extractMentionsFromDoc(docOrEditor: any): ExtractedMention[] {\n if (!docOrEditor) return [];\n const mentions: ExtractedMention[] = [];\n\n // TipTap editor or ProseMirror Node with .descendants()\n const doc =\n docOrEditor?.state?.doc ||\n (typeof docOrEditor?.descendants === \"function\" ? docOrEditor : null);\n\n if (doc && typeof doc.descendants === \"function\") {\n doc.descendants((node: any) => {\n if (node.type?.name === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n });\n }\n });\n return mentions;\n }\n\n // JSONContent tree\n if (typeof docOrEditor === \"object\" && docOrEditor.content) {\n const walk = (nodes: any[]) => {\n for (const node of nodes) {\n if (node.type === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n });\n }\n if (Array.isArray(node.content)) {\n walk(node.content);\n }\n }\n };\n walk(docOrEditor.content);\n return mentions;\n }\n\n // HTML String\n if (typeof docOrEditor === \"string\") {\n if (typeof document !== \"undefined\") {\n const div = document.createElement(\"div\");\n div.innerHTML = docOrEditor;\n div.querySelectorAll('span[data-type=\"mention\"]').forEach((el) => {\n mentions.push({\n id: el.getAttribute(\"data-id\") || \"\",\n label: el.getAttribute(\"data-label\") || \"\",\n type: el.getAttribute(\"data-type-name\") || undefined,\n avatarUrl: el.getAttribute(\"data-avatar-url\") || undefined,\n color: el.getAttribute(\"data-color\") || undefined,\n });\n });\n } else {\n const spanRegex = /<span([^>]*data-type=[\"']mention[\"'][^>]*)>/gi;\n let match;\n while ((match = spanRegex.exec(docOrEditor)) !== null) {\n const attrStr = match[1];\n const getAttr = (name: string) => {\n const m = new RegExp(`${name}=[\"']([^\"']*)[\"']`, \"i\").exec(attrStr);\n return m ? m[1] : undefined;\n };\n mentions.push({\n id: getAttr(\"data-id\") || \"\",\n label: getAttr(\"data-label\") || \"\",\n type: getAttr(\"data-type-name\") || getAttr(\"data-entity-type\"),\n avatarUrl: getAttr(\"data-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,iBAAO,IAAI,EAAE,CAAC,IAAI;AAAA,QACpB;AACA,iBAAS,KAAK;AAAA,UACZ,IAAI,QAAQ,SAAS,KAAK;AAAA,UAC1B,OAAO,QAAQ,YAAY,KAAK;AAAA,UAChC,MAAM,QAAQ,gBAAgB,KAAK,QAAQ,kBAAkB;AAAA,UAC7D,WAAW,QAAQ,iBAAiB;AAAA,UACpC,OAAO,QAAQ,YAAY;AAAA,QAC7B,CAAC;AAAA,MACH;AAAA,IACF;AAAA,EACF;AAEA,SAAO;AACT;","names":[]}
@@ -13,8 +13,21 @@ declare function plainTextToTipTapHtml(text: string): string;
13
13
  declare function htmlToPlainText(html: string): string;
14
14
  /**
15
15
  * Extracts plain text from a TipTap editor instance, preserving newline separators
16
- * between block nodes.
16
+ * between block nodes and converting mention nodes to @label.
17
17
  */
18
18
  declare function getEditorText(editor: any): string;
19
+ interface ExtractedMention {
20
+ id: string;
21
+ label: string;
22
+ type?: string;
23
+ avatarUrl?: string;
24
+ color?: string;
25
+ [key: string]: any;
26
+ }
27
+ /**
28
+ * Traverses an editor instance, ProseMirror document, JSONContent, or HTML string
29
+ * and extracts all mention attributes without needing regex.
30
+ */
31
+ declare function extractMentionsFromDoc(docOrEditor: any): ExtractedMention[];
19
32
 
20
- export { escapeHtml, getEditorText, htmlToPlainText, plainTextToTipTapHtml };
33
+ export { type ExtractedMention, escapeHtml, extractMentionsFromDoc, getEditorText, htmlToPlainText, plainTextToTipTapHtml };
@@ -13,8 +13,21 @@ declare function plainTextToTipTapHtml(text: string): string;
13
13
  declare function htmlToPlainText(html: string): string;
14
14
  /**
15
15
  * Extracts plain text from a TipTap editor instance, preserving newline separators
16
- * between block nodes.
16
+ * between block nodes and converting mention nodes to @label.
17
17
  */
18
18
  declare function getEditorText(editor: any): string;
19
+ interface ExtractedMention {
20
+ id: string;
21
+ label: string;
22
+ type?: string;
23
+ avatarUrl?: string;
24
+ color?: string;
25
+ [key: string]: any;
26
+ }
27
+ /**
28
+ * Traverses an editor instance, ProseMirror document, JSONContent, or HTML string
29
+ * and extracts all mention attributes without needing regex.
30
+ */
31
+ declare function extractMentionsFromDoc(docOrEditor: any): ExtractedMention[];
19
32
 
20
- export { escapeHtml, getEditorText, htmlToPlainText, plainTextToTipTapHtml };
33
+ export { type ExtractedMention, escapeHtml, extractMentionsFromDoc, getEditorText, htmlToPlainText, plainTextToTipTapHtml };
@@ -12,9 +12,16 @@ function plainTextToTipTapHtml(text) {
12
12
  }
13
13
  function htmlToPlainText(html) {
14
14
  if (!html) return "";
15
+ const mentionNormalized = html.replace(
16
+ /<span[^>]*data-type=["']mention["'][^>]*data-label=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
17
+ "@$1"
18
+ ).replace(
19
+ /<span[^>]*data-type=["']mention["'][^>]*data-id=["']([^"']+)["'][^>]*>.*?<\/span>/gi,
20
+ "@$1"
21
+ );
15
22
  if (typeof document !== "undefined") {
16
23
  const tempDiv = document.createElement("div");
17
- tempDiv.innerHTML = html;
24
+ tempDiv.innerHTML = mentionNormalized;
18
25
  tempDiv.querySelectorAll("br.ProseMirror-trailingBreak").forEach((br) => br.remove());
19
26
  tempDiv.querySelectorAll("br").forEach((br) => br.replaceWith("\n"));
20
27
  const paragraphs = tempDiv.querySelectorAll("p, div, li, h1, h2, h3, h4, h5, h6");
@@ -27,7 +34,7 @@ function htmlToPlainText(html) {
27
34
  }
28
35
  return tempDiv.textContent || "";
29
36
  }
30
- return html.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
37
+ return mentionNormalized.replace(/<br\s*\/?>/gi, "\n").replace(/<\/p>/gi, "\n").replace(/<\/div>/gi, "\n").replace(/<\/li>/gi, "\n").replace(/<[^>]+>/g, "").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#039;/g, "'").trim();
31
38
  }
32
39
  function getEditorText(editor) {
33
40
  if (!editor) return "";
@@ -44,8 +51,83 @@ function getEditorText(editor) {
44
51
  }
45
52
  return "";
46
53
  }
54
+ function extractMentionsFromDoc(docOrEditor) {
55
+ if (!docOrEditor) return [];
56
+ const mentions = [];
57
+ const doc = docOrEditor?.state?.doc || (typeof docOrEditor?.descendants === "function" ? docOrEditor : null);
58
+ if (doc && typeof doc.descendants === "function") {
59
+ doc.descendants((node) => {
60
+ if (node.type?.name === "mention" && node.attrs) {
61
+ mentions.push({
62
+ id: node.attrs.id || "",
63
+ label: node.attrs.label || "",
64
+ type: node.attrs.type,
65
+ avatarUrl: node.attrs.avatarUrl,
66
+ color: node.attrs.color,
67
+ ...node.attrs
68
+ });
69
+ }
70
+ });
71
+ return mentions;
72
+ }
73
+ if (typeof docOrEditor === "object" && docOrEditor.content) {
74
+ const walk = (nodes) => {
75
+ for (const node of nodes) {
76
+ if (node.type === "mention" && node.attrs) {
77
+ mentions.push({
78
+ id: node.attrs.id || "",
79
+ label: node.attrs.label || "",
80
+ type: node.attrs.type,
81
+ avatarUrl: node.attrs.avatarUrl,
82
+ color: node.attrs.color,
83
+ ...node.attrs
84
+ });
85
+ }
86
+ if (Array.isArray(node.content)) {
87
+ walk(node.content);
88
+ }
89
+ }
90
+ };
91
+ walk(docOrEditor.content);
92
+ return mentions;
93
+ }
94
+ if (typeof docOrEditor === "string") {
95
+ if (typeof document !== "undefined") {
96
+ const div = document.createElement("div");
97
+ div.innerHTML = docOrEditor;
98
+ div.querySelectorAll('span[data-type="mention"]').forEach((el) => {
99
+ mentions.push({
100
+ id: el.getAttribute("data-id") || "",
101
+ label: el.getAttribute("data-label") || "",
102
+ type: el.getAttribute("data-type-name") || void 0,
103
+ avatarUrl: el.getAttribute("data-avatar-url") || void 0,
104
+ color: el.getAttribute("data-color") || void 0
105
+ });
106
+ });
107
+ } else {
108
+ const spanRegex = /<span([^>]*data-type=["']mention["'][^>]*)>/gi;
109
+ let match;
110
+ while ((match = spanRegex.exec(docOrEditor)) !== null) {
111
+ const attrStr = match[1];
112
+ const getAttr = (name) => {
113
+ const m = new RegExp(`${name}=["']([^"']*)["']`, "i").exec(attrStr);
114
+ return m ? m[1] : void 0;
115
+ };
116
+ mentions.push({
117
+ id: getAttr("data-id") || "",
118
+ label: getAttr("data-label") || "",
119
+ type: getAttr("data-type-name") || getAttr("data-entity-type"),
120
+ avatarUrl: getAttr("data-avatar-url"),
121
+ color: getAttr("data-color")
122
+ });
123
+ }
124
+ }
125
+ }
126
+ return mentions;
127
+ }
47
128
  export {
48
129
  escapeHtml,
130
+ extractMentionsFromDoc,
49
131
  getEditorText,
50
132
  htmlToPlainText,
51
133
  plainTextToTipTapHtml
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/serializers/plain-text.ts"],"sourcesContent":["/**\n * Escapes characters that have syntactic meaning in HTML text.\n */\nexport function escapeHtml(text: string): string {\n if (!text) return \"\";\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n}\n\n/**\n * Converts a plain-text string with newlines into HTML paragraphs suitable\n * for TipTap initial content or setContent, preserving line breaks.\n */\nexport function plainTextToTipTapHtml(text: string): string {\n if (!text) return \"<p></p>\";\n if (/<p[\\s>]/i.test(text)) {\n return text;\n }\n return text\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\r/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => `<p>${escapeHtml(line)}</p>`)\n .join(\"\");\n}\n\n/**\n * Extracts plain text from an HTML string or TipTap HTML, preserving newlines between block tags.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n if (typeof document !== \"undefined\") {\n const tempDiv = document.createElement(\"div\");\n tempDiv.innerHTML = html;\n tempDiv\n .querySelectorAll(\"br.ProseMirror-trailingBreak\")\n .forEach((br) => br.remove());\n tempDiv.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n const paragraphs = tempDiv.querySelectorAll(\"p, div, li, h1, h2, h3, h4, h5, h6\");\n if (paragraphs.length > 0) {\n const textParts: string[] = [];\n paragraphs.forEach((p) => {\n textParts.push(p.textContent || \"\");\n });\n return textParts.join(\"\\n\");\n }\n return tempDiv.textContent || \"\";\n }\n\n // Node.js fallback regex\n return html\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/p>/gi, \"\\n\")\n .replace(/<\\/div>/gi, \"\\n\")\n .replace(/<\\/li>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#039;/g, \"'\")\n .trim();\n}\n\n/**\n * Extracts plain text from a TipTap editor instance, preserving newline separators\n * between block nodes.\n */\nexport function getEditorText(editor: any): string {\n if (!editor) return \"\";\n const html = typeof editor.getHTML === \"function\" ? editor.getHTML() : \"\";\n if (html) {\n return htmlToPlainText(html);\n }\n if (typeof editor.getText === \"function\") {\n try {\n return editor.getText({ blockSeparator: \"\\n\" });\n } catch {\n return editor.getText();\n }\n }\n return \"\";\n}\n"],"mappings":";AAGO,SAAS,WAAW,MAAsB;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;AAMO,SAAS,sBAAsB,MAAsB;AAC1D,MAAI,CAAC,KAAM,QAAO;AAClB,MAAI,WAAW,KAAK,IAAI,GAAG;AACzB,WAAO;AAAA,EACT;AACA,SAAO,KACJ,QAAQ,SAAS,IAAI,EACrB,QAAQ,OAAO,IAAI,EACnB,MAAM,IA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O,QAAQ;AAAA,IACxB;AAAA,EACF;AACA,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../../src/serializers/plain-text.ts"],"sourcesContent":["/**\n * Escapes characters that have syntactic meaning in HTML text.\n */\nexport function escapeHtml(text: string): string {\n if (!text) return \"\";\n return text\n .replace(/&/g, \"&amp;\")\n .replace(/</g, \"&lt;\")\n .replace(/>/g, \"&gt;\")\n .replace(/\"/g, \"&quot;\")\n .replace(/'/g, \"&#039;\");\n}\n\n/**\n * Converts a plain-text string with newlines into HTML paragraphs suitable\n * for TipTap initial content or setContent, preserving line breaks.\n */\nexport function plainTextToTipTapHtml(text: string): string {\n if (!text) return \"<p></p>\";\n if (/<p[\\s>]/i.test(text)) {\n return text;\n }\n return text\n .replace(/\\r\\n/g, \"\\n\")\n .replace(/\\r/g, \"\\n\")\n .split(\"\\n\")\n .map((line) => `<p>${escapeHtml(line)}</p>`)\n .join(\"\");\n}\n\n/**\n * Extracts plain text from an HTML string or TipTap HTML, preserving newlines between block tags.\n */\nexport function htmlToPlainText(html: string): string {\n if (!html) return \"\";\n\n // Normalize mentions so data-label is preserved as @label even if textContent is empty\n const mentionNormalized = html\n .replace(\n /<span[^>]*data-type=[\"']mention[\"'][^>]*data-label=[\"']([^\"']+)[\"'][^>]*>.*?<\\/span>/gi,\n \"@$1\",\n )\n .replace(\n /<span[^>]*data-type=[\"']mention[\"'][^>]*data-id=[\"']([^\"']+)[\"'][^>]*>.*?<\\/span>/gi,\n \"@$1\",\n );\n\n if (typeof document !== \"undefined\") {\n const tempDiv = document.createElement(\"div\");\n tempDiv.innerHTML = mentionNormalized;\n tempDiv\n .querySelectorAll(\"br.ProseMirror-trailingBreak\")\n .forEach((br) => br.remove());\n tempDiv.querySelectorAll(\"br\").forEach((br) => br.replaceWith(\"\\n\"));\n const paragraphs = tempDiv.querySelectorAll(\"p, div, li, h1, h2, h3, h4, h5, h6\");\n if (paragraphs.length > 0) {\n const textParts: string[] = [];\n paragraphs.forEach((p) => {\n textParts.push(p.textContent || \"\");\n });\n return textParts.join(\"\\n\");\n }\n return tempDiv.textContent || \"\";\n }\n\n // Node.js fallback regex\n return mentionNormalized\n .replace(/<br\\s*\\/?>/gi, \"\\n\")\n .replace(/<\\/p>/gi, \"\\n\")\n .replace(/<\\/div>/gi, \"\\n\")\n .replace(/<\\/li>/gi, \"\\n\")\n .replace(/<[^>]+>/g, \"\")\n .replace(/&amp;/g, \"&\")\n .replace(/&lt;/g, \"<\")\n .replace(/&gt;/g, \">\")\n .replace(/&quot;/g, '\"')\n .replace(/&#039;/g, \"'\")\n .trim();\n}\n\n/**\n * Extracts plain text from a TipTap editor instance, preserving newline separators\n * between block nodes and converting mention nodes to @label.\n */\nexport function getEditorText(editor: any): string {\n if (!editor) return \"\";\n const html = typeof editor.getHTML === \"function\" ? editor.getHTML() : \"\";\n if (html) {\n return htmlToPlainText(html);\n }\n if (typeof editor.getText === \"function\") {\n try {\n return editor.getText({ blockSeparator: \"\\n\" });\n } catch {\n return editor.getText();\n }\n }\n return \"\";\n}\n\nexport interface ExtractedMention {\n id: string;\n label: string;\n type?: string;\n avatarUrl?: string;\n color?: string;\n [key: string]: any;\n}\n\n/**\n * Traverses an editor instance, ProseMirror document, JSONContent, or HTML string\n * and extracts all mention attributes without needing regex.\n */\nexport function extractMentionsFromDoc(docOrEditor: any): ExtractedMention[] {\n if (!docOrEditor) return [];\n const mentions: ExtractedMention[] = [];\n\n // TipTap editor or ProseMirror Node with .descendants()\n const doc =\n docOrEditor?.state?.doc ||\n (typeof docOrEditor?.descendants === \"function\" ? docOrEditor : null);\n\n if (doc && typeof doc.descendants === \"function\") {\n doc.descendants((node: any) => {\n if (node.type?.name === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n });\n }\n });\n return mentions;\n }\n\n // JSONContent tree\n if (typeof docOrEditor === \"object\" && docOrEditor.content) {\n const walk = (nodes: any[]) => {\n for (const node of nodes) {\n if (node.type === \"mention\" && node.attrs) {\n mentions.push({\n id: node.attrs.id || \"\",\n label: node.attrs.label || \"\",\n type: node.attrs.type,\n avatarUrl: node.attrs.avatarUrl,\n color: node.attrs.color,\n ...node.attrs,\n });\n }\n if (Array.isArray(node.content)) {\n walk(node.content);\n }\n }\n };\n walk(docOrEditor.content);\n return mentions;\n }\n\n // HTML String\n if (typeof docOrEditor === \"string\") {\n if (typeof document !== \"undefined\") {\n const div = document.createElement(\"div\");\n div.innerHTML = docOrEditor;\n div.querySelectorAll('span[data-type=\"mention\"]').forEach((el) => {\n mentions.push({\n id: el.getAttribute(\"data-id\") || \"\",\n label: el.getAttribute(\"data-label\") || \"\",\n type: el.getAttribute(\"data-type-name\") || undefined,\n avatarUrl: el.getAttribute(\"data-avatar-url\") || undefined,\n color: el.getAttribute(\"data-color\") || undefined,\n });\n });\n } else {\n const spanRegex = /<span([^>]*data-type=[\"']mention[\"'][^>]*)>/gi;\n let match;\n while ((match = spanRegex.exec(docOrEditor)) !== null) {\n const attrStr = match[1];\n const getAttr = (name: string) => {\n const m = new RegExp(`${name}=[\"']([^\"']*)[\"']`, \"i\").exec(attrStr);\n return m ? m[1] : undefined;\n };\n mentions.push({\n id: getAttr(\"data-id\") || \"\",\n label: getAttr(\"data-label\") || \"\",\n type: getAttr(\"data-type-name\") || getAttr(\"data-entity-type\"),\n avatarUrl: getAttr(\"data-avatar-url\"),\n color: getAttr(\"data-color\"),\n });\n }\n }\n }\n\n return mentions;\n}\n"],"mappings":";AAGO,SAAS,WAAW,MAAsB;AAC/C,MAAI,CAAC,KAAM,QAAO;AAClB,SAAO,KACJ,QAAQ,MAAM,OAAO,EACrB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,MAAM,EACpB,QAAQ,MAAM,QAAQ,EACtB,QAAQ,MAAM,QAAQ;AAC3B;AAMO,SAAS,sBAAsB,MAAsB;AAC1D,MAAI,CAA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
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "UI-agnostic rich text and media editing core library",
5
5
  "author": "Pixerate",
6
6
  "license": "MIT",
@@ -44,6 +44,7 @@
44
44
  "@tiptap/extension-color": "^2.11.5",
45
45
  "@tiptap/extension-highlight": "^2.11.5",
46
46
  "@tiptap/extension-link": "^2.11.5",
47
+ "@tiptap/extension-mention": "^2.11.5",
47
48
  "@tiptap/extension-placeholder": "^2.11.5",
48
49
  "@tiptap/extension-subscript": "^2.11.5",
49
50
  "@tiptap/extension-superscript": "^2.11.5",