@pocketping/widget 1.10.0 → 1.11.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/dist/index.cjs +62 -1
- package/dist/index.js +62 -1
- package/dist/pocketping.min.global.js +41 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -515,6 +515,33 @@ function styles(options) {
|
|
|
515
515
|
display: inline;
|
|
516
516
|
}
|
|
517
517
|
|
|
518
|
+
/* Markdown styles */
|
|
519
|
+
.pp-message-content strong {
|
|
520
|
+
font-weight: 600;
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
.pp-message-content em {
|
|
524
|
+
font-style: italic;
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
.pp-message-content code {
|
|
528
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
529
|
+
font-size: 0.9em;
|
|
530
|
+
background: ${isDark ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.06)"};
|
|
531
|
+
padding: 1px 4px;
|
|
532
|
+
border-radius: 3px;
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
.pp-md-list {
|
|
536
|
+
margin: 4px 0;
|
|
537
|
+
padding-left: 20px;
|
|
538
|
+
display: block;
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
.pp-md-list li {
|
|
542
|
+
margin: 2px 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
518
545
|
/* WhatsApp-style inline timestamp - floats to the right */
|
|
519
546
|
.pp-message-time {
|
|
520
547
|
font-size: 11px;
|
|
@@ -1886,6 +1913,40 @@ function PreChatForm({ client: client2, config, onComplete, onSkip }) {
|
|
|
1886
1913
|
] });
|
|
1887
1914
|
}
|
|
1888
1915
|
|
|
1916
|
+
// src/utils/markdown.ts
|
|
1917
|
+
function renderMarkdown(text) {
|
|
1918
|
+
if (!text) return "";
|
|
1919
|
+
let html = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1920
|
+
const lines = html.split("\n");
|
|
1921
|
+
let inList = false;
|
|
1922
|
+
const processedLines = [];
|
|
1923
|
+
for (const line of lines) {
|
|
1924
|
+
const listMatch = line.match(/^[\s]*[*-]\s+(.+)$/);
|
|
1925
|
+
if (listMatch) {
|
|
1926
|
+
if (!inList) {
|
|
1927
|
+
processedLines.push('<ul class="pp-md-list">');
|
|
1928
|
+
inList = true;
|
|
1929
|
+
}
|
|
1930
|
+
processedLines.push(`<li>${processInline(listMatch[1])}</li>`);
|
|
1931
|
+
} else {
|
|
1932
|
+
if (inList) {
|
|
1933
|
+
processedLines.push("</ul>");
|
|
1934
|
+
inList = false;
|
|
1935
|
+
}
|
|
1936
|
+
processedLines.push(processInline(line));
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
if (inList) {
|
|
1940
|
+
processedLines.push("</ul>");
|
|
1941
|
+
}
|
|
1942
|
+
html = processedLines.join("<br />");
|
|
1943
|
+
html = html.replace(/<br \/><ul/g, "<ul").replace(/<\/ul><br \/>/g, "</ul>").replace(/<br \/><li>/g, "<li>").replace(/<\/li><br \/>/g, "</li>");
|
|
1944
|
+
return html;
|
|
1945
|
+
}
|
|
1946
|
+
function processInline(text) {
|
|
1947
|
+
return text.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/__(.+?)__/g, "<strong>$1</strong>").replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, "<em>$1</em>").replace(/(?<!_)_([^_]+)_(?!_)/g, "<em>$1</em>").replace(/`([^`]+)`/g, "<code>$1</code>");
|
|
1948
|
+
}
|
|
1949
|
+
|
|
1889
1950
|
// src/components/ChatWidget.tsx
|
|
1890
1951
|
var import_jsx_runtime2 = require("preact/jsx-runtime");
|
|
1891
1952
|
function formatDateSeparator(date) {
|
|
@@ -2468,7 +2529,7 @@ function ChatWidget({ client: client2, config: initialConfig }) {
|
|
|
2468
2529
|
" Message deleted"
|
|
2469
2530
|
] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
2470
2531
|
msg.content && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { class: "pp-message-content", children: [
|
|
2471
|
-
msg.content,
|
|
2532
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { dangerouslySetInnerHTML: { __html: renderMarkdown(msg.content) } }),
|
|
2472
2533
|
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { class: "pp-message-time", children: [
|
|
2473
2534
|
formatTime(msg.timestamp),
|
|
2474
2535
|
isEdited && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { class: "pp-edited-badge", children: "edited" }),
|
package/dist/index.js
CHANGED
|
@@ -474,6 +474,33 @@ function styles(options) {
|
|
|
474
474
|
display: inline;
|
|
475
475
|
}
|
|
476
476
|
|
|
477
|
+
/* Markdown styles */
|
|
478
|
+
.pp-message-content strong {
|
|
479
|
+
font-weight: 600;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
.pp-message-content em {
|
|
483
|
+
font-style: italic;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
.pp-message-content code {
|
|
487
|
+
font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
|
488
|
+
font-size: 0.9em;
|
|
489
|
+
background: ${isDark ? "rgba(255,255,255,0.1)" : "rgba(0,0,0,0.06)"};
|
|
490
|
+
padding: 1px 4px;
|
|
491
|
+
border-radius: 3px;
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.pp-md-list {
|
|
495
|
+
margin: 4px 0;
|
|
496
|
+
padding-left: 20px;
|
|
497
|
+
display: block;
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
.pp-md-list li {
|
|
501
|
+
margin: 2px 0;
|
|
502
|
+
}
|
|
503
|
+
|
|
477
504
|
/* WhatsApp-style inline timestamp - floats to the right */
|
|
478
505
|
.pp-message-time {
|
|
479
506
|
font-size: 11px;
|
|
@@ -1845,6 +1872,40 @@ function PreChatForm({ client: client2, config, onComplete, onSkip }) {
|
|
|
1845
1872
|
] });
|
|
1846
1873
|
}
|
|
1847
1874
|
|
|
1875
|
+
// src/utils/markdown.ts
|
|
1876
|
+
function renderMarkdown(text) {
|
|
1877
|
+
if (!text) return "";
|
|
1878
|
+
let html = text.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
1879
|
+
const lines = html.split("\n");
|
|
1880
|
+
let inList = false;
|
|
1881
|
+
const processedLines = [];
|
|
1882
|
+
for (const line of lines) {
|
|
1883
|
+
const listMatch = line.match(/^[\s]*[*-]\s+(.+)$/);
|
|
1884
|
+
if (listMatch) {
|
|
1885
|
+
if (!inList) {
|
|
1886
|
+
processedLines.push('<ul class="pp-md-list">');
|
|
1887
|
+
inList = true;
|
|
1888
|
+
}
|
|
1889
|
+
processedLines.push(`<li>${processInline(listMatch[1])}</li>`);
|
|
1890
|
+
} else {
|
|
1891
|
+
if (inList) {
|
|
1892
|
+
processedLines.push("</ul>");
|
|
1893
|
+
inList = false;
|
|
1894
|
+
}
|
|
1895
|
+
processedLines.push(processInline(line));
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
if (inList) {
|
|
1899
|
+
processedLines.push("</ul>");
|
|
1900
|
+
}
|
|
1901
|
+
html = processedLines.join("<br />");
|
|
1902
|
+
html = html.replace(/<br \/><ul/g, "<ul").replace(/<\/ul><br \/>/g, "</ul>").replace(/<br \/><li>/g, "<li>").replace(/<\/li><br \/>/g, "</li>");
|
|
1903
|
+
return html;
|
|
1904
|
+
}
|
|
1905
|
+
function processInline(text) {
|
|
1906
|
+
return text.replace(/\*\*(.+?)\*\*/g, "<strong>$1</strong>").replace(/__(.+?)__/g, "<strong>$1</strong>").replace(/(?<!\*)\*([^*]+)\*(?!\*)/g, "<em>$1</em>").replace(/(?<!_)_([^_]+)_(?!_)/g, "<em>$1</em>").replace(/`([^`]+)`/g, "<code>$1</code>");
|
|
1907
|
+
}
|
|
1908
|
+
|
|
1848
1909
|
// src/components/ChatWidget.tsx
|
|
1849
1910
|
import { Fragment as Fragment3, jsx as jsx2, jsxs as jsxs2 } from "preact/jsx-runtime";
|
|
1850
1911
|
function formatDateSeparator(date) {
|
|
@@ -2427,7 +2488,7 @@ function ChatWidget({ client: client2, config: initialConfig }) {
|
|
|
2427
2488
|
" Message deleted"
|
|
2428
2489
|
] }) : /* @__PURE__ */ jsxs2(Fragment3, { children: [
|
|
2429
2490
|
msg.content && /* @__PURE__ */ jsxs2("div", { class: "pp-message-content", children: [
|
|
2430
|
-
msg.content,
|
|
2491
|
+
/* @__PURE__ */ jsx2("span", { dangerouslySetInnerHTML: { __html: renderMarkdown(msg.content) } }),
|
|
2431
2492
|
/* @__PURE__ */ jsxs2("span", { class: "pp-message-time", children: [
|
|
2432
2493
|
formatTime(msg.timestamp),
|
|
2433
2494
|
isEdited && /* @__PURE__ */ jsx2("span", { class: "pp-edited-badge", children: "edited" }),
|