@examplary/ui 1.56.0 → 1.60.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.
Files changed (107) hide show
  1. package/dist/components/ai/ai-icon.js +2 -25
  2. package/dist/components/ai/ai-prompt-suggestion.js +3 -26
  3. package/dist/components/brand/tick-icon.js +2 -25
  4. package/dist/components/chat/chat-input.js +8 -31
  5. package/dist/components/chat/chat-typing-indicator.js +2 -2
  6. package/dist/components/chat/chat-view.d.ts +1 -5
  7. package/dist/components/chat/chat-view.js +8 -36
  8. package/dist/components/loading/ai-spinner.js +2 -13
  9. package/dist/components/loading/tick-loader.js +39 -104
  10. package/dist/components/print/answer-box.js +2 -25
  11. package/dist/components/question-types/fetch-component.js +65 -106
  12. package/dist/components/question-types/format-question-type.d.ts +41 -41
  13. package/dist/components/question-types/format-question-type.js +36 -37
  14. package/dist/components/rich-text/minimal-rich-text-field.d.ts +2 -2
  15. package/dist/components/rich-text/minimal-rich-text-field.js +47 -85
  16. package/dist/components/rich-text/rich-text-display.js +15 -33
  17. package/dist/components/rich-text/rich-text-field.js +2 -25
  18. package/dist/components/rich-text/rich-text-toolbar.d.ts +3 -2
  19. package/dist/components/rich-text/rich-text-toolbar.js +5 -6
  20. package/dist/components/rich-text/tiptap/collaboration-caret.js +24 -34
  21. package/dist/components/rich-text/tiptap/comments/comment-bubble.d.ts +1 -1
  22. package/dist/components/rich-text/tiptap/comments/comment-bubble.js +36 -41
  23. package/dist/components/rich-text/tiptap/content-reference.js +6 -7
  24. package/dist/components/rich-text/tiptap/crop-page-clipping-modal.d.ts +3 -3
  25. package/dist/components/rich-text/tiptap/crop-page-clipping-modal.js +20 -25
  26. package/dist/components/rich-text/tiptap/extensions.d.ts +2 -2
  27. package/dist/components/rich-text/tiptap/extensions.js +6 -16
  28. package/dist/components/rich-text/tiptap/file-attachment.js +9 -11
  29. package/dist/components/rich-text/tiptap/file-handler.d.ts +2 -2
  30. package/dist/components/rich-text/tiptap/file-handler.js +110 -185
  31. package/dist/components/rich-text/tiptap/image.js +18 -23
  32. package/dist/components/rich-text/tiptap/mathematics-component.js +25 -30
  33. package/dist/components/rich-text/tiptap/mathematics.js +56 -82
  34. package/dist/components/rich-text/tiptap/page-clipping.js +3 -4
  35. package/dist/components/rich-text/tiptap/png-scanner.js +63 -108
  36. package/dist/components/rich-text/tiptap/rich-text-formatting-menu.d.ts +1 -1
  37. package/dist/components/rich-text/tiptap/rich-text-formatting-menu.js +31 -47
  38. package/dist/components/ui/alert.d.ts +3 -3
  39. package/dist/components/ui/alert.js +7 -32
  40. package/dist/components/ui/avatar.d.ts +2 -1
  41. package/dist/components/ui/avatar.js +33 -26
  42. package/dist/components/ui/badge.d.ts +3 -3
  43. package/dist/components/ui/badge.js +4 -27
  44. package/dist/components/ui/button.d.ts +4 -4
  45. package/dist/components/ui/button.js +4 -27
  46. package/dist/components/ui/card.js +6 -46
  47. package/dist/components/ui/checkbox.js +1 -26
  48. package/dist/components/ui/color-picker.js +11 -22
  49. package/dist/components/ui/command-palette.d.ts +3 -3
  50. package/dist/components/ui/command-palette.js +54 -73
  51. package/dist/components/ui/command.js +18 -49
  52. package/dist/components/ui/comments.js +37 -107
  53. package/dist/components/ui/context-menu.js +30 -67
  54. package/dist/components/ui/dialog.js +15 -61
  55. package/dist/components/ui/dropdown.js +17 -64
  56. package/dist/components/ui/floating-menu.js +2 -25
  57. package/dist/components/ui/floating-resizable.d.ts +5 -0
  58. package/dist/components/ui/floating-resizable.js +24 -0
  59. package/dist/components/ui/help-icon.js +1 -2
  60. package/dist/components/ui/icon-picker.js +50 -130
  61. package/dist/components/ui/index.d.ts +1 -0
  62. package/dist/components/ui/index.js +1 -0
  63. package/dist/components/ui/input.js +2 -25
  64. package/dist/components/ui/label.d.ts +1 -1
  65. package/dist/components/ui/label.js +2 -27
  66. package/dist/components/ui/popover.d.ts +2 -2
  67. package/dist/components/ui/popover.js +4 -32
  68. package/dist/components/ui/progress-bar.js +2 -3
  69. package/dist/components/ui/radio-group.js +4 -28
  70. package/dist/components/ui/resizable.d.ts +6 -9
  71. package/dist/components/ui/resizable.js +13 -60
  72. package/dist/components/ui/select.js +12 -55
  73. package/dist/components/ui/separator.js +1 -26
  74. package/dist/components/ui/sheet.d.ts +3 -3
  75. package/dist/components/ui/sheet.js +11 -51
  76. package/dist/components/ui/skeleton.js +2 -25
  77. package/dist/components/ui/slider.js +7 -32
  78. package/dist/components/ui/sortable.d.ts +1 -1
  79. package/dist/components/ui/sortable.js +131 -155
  80. package/dist/components/ui/switch.d.ts +3 -3
  81. package/dist/components/ui/switch.js +3 -28
  82. package/dist/components/ui/table.js +8 -54
  83. package/dist/components/ui/tabs.js +8 -34
  84. package/dist/components/ui/text-selection-menu.d.ts +1 -1
  85. package/dist/components/ui/text-selection-menu.js +19 -25
  86. package/dist/components/ui/textarea.js +7 -30
  87. package/dist/components/ui/tooltip.js +4 -29
  88. package/dist/components/web-components/content-reference.js +81 -106
  89. package/dist/components/web-components/file-attachment.js +9 -30
  90. package/dist/components/web-components/index.js +1 -1
  91. package/dist/components/web-components/inline-comment-reply.js +3 -24
  92. package/dist/components/web-components/inline-comment.js +3 -24
  93. package/dist/components/web-components/inline-math.js +14 -36
  94. package/dist/components/web-components/page-clipping.js +13 -34
  95. package/dist/lib/compose-refs.js +10 -18
  96. package/dist/lib/use-spin-loop.js +19 -69
  97. package/dist/src/global.css +2 -2
  98. package/dist/utils.js +1 -5
  99. package/package.json +5 -4
  100. package/dist/components/rich-text/tiptap/comments/comment-reply.d.ts +0 -21
  101. package/dist/components/rich-text/tiptap/comments/comment-reply.js +0 -230
  102. package/dist/components/rich-text/tiptap/comments/comment.d.ts +0 -22
  103. package/dist/components/rich-text/tiptap/comments/comment.js +0 -198
  104. package/dist/components/rich-text/tiptap/comments/helpers.d.ts +0 -19
  105. package/dist/components/rich-text/tiptap/comments/helpers.js +0 -95
  106. package/dist/components/rich-text/tiptap/comments/types.d.ts +0 -29
  107. package/dist/components/rich-text/tiptap/comments/types.js +0 -1
@@ -1,62 +1,56 @@
1
1
  import { jsx as _jsx } from "react/jsx-runtime";
2
2
  import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
3
3
  import { offset, useFloating } from "@floating-ui/react";
4
- var TextSelectionContext = createContext(null);
5
- export var TextSelectionContainer = function (_a) {
6
- var children = _a.children, _b = _a.enabled, enabled = _b === void 0 ? true : _b;
7
- var containerRef = useRef(null);
8
- var _c = useState(null), selection = _c[0], setSelection = _c[1];
9
- var handleSelection = useCallback(function () {
4
+ const TextSelectionContext = createContext(null);
5
+ export const TextSelectionContainer = ({ children, enabled = true, }) => {
6
+ const containerRef = useRef(null);
7
+ const [selection, setSelection] = useState(null);
8
+ const handleSelection = useCallback(() => {
10
9
  if (!enabled)
11
10
  return;
12
- var sel = window.getSelection();
11
+ const sel = window.getSelection();
13
12
  // No selection or collapsed (just a cursor)
14
13
  if (!sel || sel.isCollapsed || sel.rangeCount === 0) {
15
14
  setSelection(null);
16
15
  return;
17
16
  }
18
- var range = sel.getRangeAt(0);
17
+ const range = sel.getRangeAt(0);
19
18
  // Only react to selections inside our editor
20
19
  if (containerRef.current &&
21
20
  !containerRef.current.contains(range.commonAncestorContainer)) {
22
21
  setSelection(null);
23
22
  return;
24
23
  }
25
- var rect = range.getBoundingClientRect();
24
+ const rect = range.getBoundingClientRect();
26
25
  if (rect.width === 0 && rect.height === 0) {
27
26
  setSelection(null);
28
27
  return;
29
28
  }
30
- setSelection({ text: sel.toString(), range: range, rect: rect });
29
+ setSelection({ text: sel.toString(), range, rect });
31
30
  }, [containerRef, enabled]);
32
- useEffect(function () {
31
+ useEffect(() => {
33
32
  if (!enabled) {
34
33
  // eslint-disable-next-line react-hooks/set-state-in-effect
35
34
  setSelection(null);
36
35
  return;
37
36
  }
38
37
  document.addEventListener("selectionchange", handleSelection);
39
- return function () {
40
- return document.removeEventListener("selectionchange", handleSelection);
41
- };
38
+ return () => document.removeEventListener("selectionchange", handleSelection);
42
39
  }, [handleSelection, enabled]);
43
- return (_jsx(TextSelectionContext.Provider, { value: { selection: selection, setSelection: setSelection }, children: _jsx("div", { ref: containerRef, children: children }) }));
40
+ return (_jsx(TextSelectionContext.Provider, { value: { selection, setSelection }, children: _jsx("div", { ref: containerRef, children: children }) }));
44
41
  };
45
- export var TextSelectionMenu = function (_a) {
46
- var children = _a.children, _b = _a.placement, placement = _b === void 0 ? "top" : _b;
47
- var _c = useContext(TextSelectionContext), selection = _c.selection, setSelection = _c.setSelection;
48
- var _d = useFloating({
49
- placement: placement,
42
+ export const TextSelectionMenu = ({ children, placement = "top", }) => {
43
+ const { selection, setSelection } = useContext(TextSelectionContext);
44
+ const { refs, floatingStyles } = useFloating({
45
+ placement,
50
46
  strategy: "absolute",
51
47
  middleware: [offset(8)],
52
48
  elements: {
53
49
  // sadly mis-typed in the library
54
- reference: selection === null || selection === void 0 ? void 0 : selection.range,
50
+ reference: selection?.range,
55
51
  },
56
- }), refs = _d.refs, floatingStyles = _d.floatingStyles;
52
+ });
57
53
  if (!selection)
58
54
  return null;
59
- return (
60
- // eslint-disable-next-line react-hooks/refs
61
- _jsx("div", { ref: refs.setFloating, style: floatingStyles, className: "z-10", children: children(selection, setSelection) }));
55
+ return (_jsx("div", { ref: refs.setFloating, style: floatingStyles, className: "z-10", children: children(selection, setSelection) }));
62
56
  };
@@ -1,41 +1,18 @@
1
- var __assign = (this && this.__assign) || function () {
2
- __assign = Object.assign || function(t) {
3
- for (var s, i = 1, n = arguments.length; i < n; i++) {
4
- s = arguments[i];
5
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
- t[p] = s[p];
7
- }
8
- return t;
9
- };
10
- return __assign.apply(this, arguments);
11
- };
12
- var __rest = (this && this.__rest) || function (s, e) {
13
- var t = {};
14
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
15
- t[p] = s[p];
16
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
17
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
18
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
19
- t[p[i]] = s[p[i]];
20
- }
21
- return t;
22
- };
23
1
  import { jsx as _jsx } from "react/jsx-runtime";
24
2
  import * as React from "react";
25
3
  import { useEffect, useRef } from "react";
26
4
  import { cn } from "../../utils";
27
- var Textarea = React.forwardRef(function (_a, ref) {
28
- var className = _a.className, autoGrow = _a.autoGrow, props = __rest(_a, ["className", "autoGrow"]);
29
- var selfRef = useRef(null);
30
- useEffect(function () {
31
- var target = ref || selfRef;
5
+ const Textarea = React.forwardRef(({ className, autoGrow, ...props }, ref) => {
6
+ const selfRef = useRef(null);
7
+ useEffect(() => {
8
+ const target = ref || selfRef;
32
9
  if (autoGrow && target && "current" in target) {
33
- var element = target.current;
10
+ const element = target.current;
34
11
  element.style.height = "auto";
35
- element.style.height = "".concat(element.scrollHeight, "px");
12
+ element.style.height = `${element.scrollHeight}px`;
36
13
  }
37
14
  }, [autoGrow, ref, props.value, props.defaultValue]);
38
- return (_jsx("textarea", __assign({ className: cn("flex min-h-[80px] w-full rounded-lg border text-text font-base selection:bg-main selection:text-text placeholder:text-zinc-500 border-border bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-text placeholder:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref || selfRef }, props)));
15
+ return (_jsx("textarea", { className: cn("flex min-h-[80px] w-full rounded-lg border text-text font-base selection:bg-main selection:text-text placeholder:text-zinc-500 border-border bg-white px-3 py-2 text-sm ring-offset-white placeholder:text-text placeholder:opacity-50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50", className), ref: ref || selfRef, ...props }));
39
16
  });
40
17
  Textarea.displayName = "Textarea";
41
18
  export { Textarea };
@@ -1,36 +1,11 @@
1
1
  "use client";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
2
  import { jsx as _jsx } from "react/jsx-runtime";
25
3
  import * as React from "react";
26
4
  import * as TooltipPrimitive from "@radix-ui/react-tooltip";
27
5
  import { cn } from "../../utils";
28
- var TooltipProvider = TooltipPrimitive.Provider;
29
- var Tooltip = TooltipPrimitive.Root;
30
- var TooltipTrigger = TooltipPrimitive.Trigger;
31
- var TooltipContent = React.forwardRef(function (_a, ref) {
32
- var className = _a.className, _b = _a.sideOffset, sideOffset = _b === void 0 ? 4 : _b, props = __rest(_a, ["className", "sideOffset"]);
33
- return (_jsx(TooltipPrimitive.Content, __assign({ ref: ref, collisionPadding: 8, sideOffset: sideOffset, className: cn("z-50 overflow-hidden border px-4 font-medium text-sm py-1 rounded-3xl shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-neutral-800 bg-neutral-950 text-neutral-50", className) }, props)));
34
- });
6
+ const TooltipProvider = TooltipPrimitive.Provider;
7
+ const Tooltip = TooltipPrimitive.Root;
8
+ const TooltipTrigger = TooltipPrimitive.Trigger;
9
+ const TooltipContent = React.forwardRef(({ className, sideOffset = 4, ...props }, ref) => (_jsx(TooltipPrimitive.Content, { ref: ref, collisionPadding: 8, sideOffset: sideOffset, className: cn("z-50 overflow-hidden border px-4 font-medium text-sm py-1 rounded-3xl shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 border-neutral-800 bg-neutral-950 text-neutral-50", className), ...props })));
35
10
  TooltipContent.displayName = TooltipPrimitive.Content.displayName;
36
11
  export { Tooltip, TooltipTrigger, TooltipContent, TooltipProvider };
@@ -1,98 +1,7 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var ContentReferenceElement = /** @class */ (function (_super) {
18
- __extends(ContentReferenceElement, _super);
19
- function ContentReferenceElement() {
20
- var _this = _super !== null && _super.apply(this, arguments) || this;
21
- _this.targetEl = null;
22
- _this.timeout = null;
23
- _this.handleClick = function () {
24
- var _a, _b;
25
- _this.handleEnter();
26
- // Scroll new highlight into view
27
- var highlight = (_a = _this.targetEl) === null || _a === void 0 ? void 0 : _a.querySelector("mark.content-reference-highlight");
28
- if (highlight) {
29
- (_b = highlight.scrollIntoView) === null || _b === void 0 ? void 0 : _b.call(highlight, {
30
- behavior: "smooth",
31
- block: "center",
32
- });
33
- }
34
- if (_this.timeout)
35
- clearTimeout(_this.timeout);
36
- _this.timeout = setTimeout(function () {
37
- _this.timeout = null;
38
- _this.restore();
39
- }, 2000);
40
- };
41
- _this.handleEnter = function () {
42
- var parent = _this.closest("[data-content-reference-target]");
43
- var targetId = parent === null || parent === void 0 ? void 0 : parent.dataset.contentReferenceTarget;
44
- if (!targetId)
45
- return;
46
- var target = document.getElementById(targetId);
47
- if (!target)
48
- return;
49
- var quote = _this.getAttribute("quote");
50
- if (!quote)
51
- return;
52
- var textNodes = [];
53
- var walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
54
- var pos = 0;
55
- var current;
56
- while ((current = walker.nextNode())) {
57
- var text = current;
58
- var len = text.data.length;
59
- textNodes.push({ node: text, start: pos, end: pos + len });
60
- pos += len;
61
- }
62
- var haystack = textNodes.map(function (n) { return n.node.data; }).join("");
63
- var matchAt = haystack.indexOf(quote);
64
- if (matchAt < 0)
65
- return;
66
- var matchEnd = matchAt + quote.length;
67
- _this.targetEl = target;
68
- for (var _i = 0, textNodes_1 = textNodes; _i < textNodes_1.length; _i++) {
69
- var _a = textNodes_1[_i], node = _a.node, start = _a.start, end = _a.end;
70
- if (end <= matchAt)
71
- continue;
72
- if (start >= matchEnd)
73
- break;
74
- var localStart = Math.max(0, matchAt - start);
75
- var localEnd = Math.min(node.data.length, matchEnd - start);
76
- if (localStart >= localEnd)
77
- continue;
78
- var middle = localStart > 0 ? node.splitText(localStart) : node;
79
- if (localEnd - localStart < middle.data.length) {
80
- middle.splitText(localEnd - localStart);
81
- }
82
- var mark = document.createElement("mark");
83
- mark.className = "content-reference-highlight";
84
- middle.parentNode.insertBefore(mark, middle);
85
- mark.appendChild(middle);
86
- }
87
- };
88
- _this.handleLeave = function () {
89
- if (_this.timeout)
90
- return;
91
- _this.restore();
92
- };
93
- return _this;
94
- }
95
- ContentReferenceElement.prototype.connectedCallback = function () {
2
+ export class ContentReferenceElement extends HTMLElement {
3
+ targetEl = null;
4
+ connectedCallback() {
96
5
  if (!this.hasAttribute("tabindex"))
97
6
  this.tabIndex = 0;
98
7
  if (!this.hasAttribute("role"))
@@ -106,8 +15,8 @@ var ContentReferenceElement = /** @class */ (function (_super) {
106
15
  this.addEventListener("touchstart", this.handleClick);
107
16
  this.addEventListener("focus", this.handleEnter);
108
17
  this.addEventListener("blur", this.handleLeave);
109
- };
110
- ContentReferenceElement.prototype.disconnectedCallback = function () {
18
+ }
19
+ disconnectedCallback() {
111
20
  this.removeEventListener("mouseenter", this.handleEnter);
112
21
  this.removeEventListener("mouseleave", this.handleLeave);
113
22
  this.removeEventListener("click", this.handleClick);
@@ -115,28 +24,94 @@ var ContentReferenceElement = /** @class */ (function (_super) {
115
24
  this.removeEventListener("focus", this.handleEnter);
116
25
  this.removeEventListener("blur", this.handleLeave);
117
26
  this.restore();
27
+ }
28
+ timeout = null;
29
+ handleClick = () => {
30
+ this.handleEnter();
31
+ // Scroll new highlight into view
32
+ const highlight = this.targetEl?.querySelector("mark.content-reference-highlight");
33
+ if (highlight) {
34
+ highlight.scrollIntoView?.({
35
+ behavior: "smooth",
36
+ block: "center",
37
+ });
38
+ }
39
+ if (this.timeout)
40
+ clearTimeout(this.timeout);
41
+ this.timeout = setTimeout(() => {
42
+ this.timeout = null;
43
+ this.restore();
44
+ }, 2000);
45
+ };
46
+ handleEnter = () => {
47
+ const parent = this.closest("[data-content-reference-target]");
48
+ const targetId = parent?.dataset.contentReferenceTarget;
49
+ if (!targetId)
50
+ return;
51
+ const target = document.getElementById(targetId);
52
+ if (!target)
53
+ return;
54
+ const quote = this.getAttribute("quote");
55
+ if (!quote)
56
+ return;
57
+ const textNodes = [];
58
+ const walker = document.createTreeWalker(target, NodeFilter.SHOW_TEXT);
59
+ let pos = 0;
60
+ let current;
61
+ while ((current = walker.nextNode())) {
62
+ const text = current;
63
+ const len = text.data.length;
64
+ textNodes.push({ node: text, start: pos, end: pos + len });
65
+ pos += len;
66
+ }
67
+ const haystack = textNodes.map((n) => n.node.data).join("");
68
+ const matchAt = haystack.indexOf(quote);
69
+ if (matchAt < 0)
70
+ return;
71
+ const matchEnd = matchAt + quote.length;
72
+ this.targetEl = target;
73
+ for (const { node, start, end } of textNodes) {
74
+ if (end <= matchAt)
75
+ continue;
76
+ if (start >= matchEnd)
77
+ break;
78
+ const localStart = Math.max(0, matchAt - start);
79
+ const localEnd = Math.min(node.data.length, matchEnd - start);
80
+ if (localStart >= localEnd)
81
+ continue;
82
+ const middle = localStart > 0 ? node.splitText(localStart) : node;
83
+ if (localEnd - localStart < middle.data.length) {
84
+ middle.splitText(localEnd - localStart);
85
+ }
86
+ const mark = document.createElement("mark");
87
+ mark.className = "content-reference-highlight";
88
+ middle.parentNode.insertBefore(mark, middle);
89
+ mark.appendChild(middle);
90
+ }
91
+ };
92
+ handleLeave = () => {
93
+ if (this.timeout)
94
+ return;
95
+ this.restore();
118
96
  };
119
- ContentReferenceElement.prototype.restore = function () {
97
+ restore() {
120
98
  if (this.timeout) {
121
99
  clearTimeout(this.timeout);
122
100
  this.timeout = null;
123
101
  }
124
102
  if (!this.targetEl)
125
103
  return;
126
- var highlights = this.targetEl.querySelectorAll("mark.content-reference-highlight");
127
- highlights.forEach(function (highlight) {
128
- var _a, _b;
129
- var parent = highlight.parentNode;
104
+ const highlights = this.targetEl.querySelectorAll("mark.content-reference-highlight");
105
+ highlights.forEach((highlight) => {
106
+ const parent = highlight.parentNode;
130
107
  if (!parent)
131
108
  return;
132
109
  while (highlight.firstChild) {
133
110
  parent.insertBefore(highlight.firstChild, highlight);
134
111
  }
135
112
  parent.removeChild(highlight);
136
- (_b = (_a = parent).normalize) === null || _b === void 0 ? void 0 : _b.call(_a);
113
+ parent.normalize?.();
137
114
  });
138
115
  this.targetEl = null;
139
- };
140
- return ContentReferenceElement;
141
- }(HTMLElement));
142
- export { ContentReferenceElement };
116
+ }
117
+ }
@@ -1,30 +1,11 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  import { cn } from "../../utils";
18
- var FileAttachmentElement = /** @class */ (function (_super) {
19
- __extends(FileAttachmentElement, _super);
20
- function FileAttachmentElement() {
21
- return _super !== null && _super.apply(this, arguments) || this;
22
- }
23
- FileAttachmentElement.prototype.connectedCallback = function () {
24
- var title = this.getAttribute("title") || "File";
25
- var href = this.getAttribute("href") || "#";
3
+ export class FileAttachmentElement extends HTMLElement {
4
+ connectedCallback() {
5
+ const title = this.getAttribute("title") || "File";
6
+ const href = this.getAttribute("href") || "#";
26
7
  // Create React root and render component
27
- var a = document.createElement("a");
8
+ const a = document.createElement("a");
28
9
  a.href = href;
29
10
  a.target = "_blank";
30
11
  a.rel = "noopener noreferrer";
@@ -34,17 +15,15 @@ var FileAttachmentElement = /** @class */ (function (_super) {
34
15
  if (this.closest(".ProseMirror")) {
35
16
  a.className = cn(a.className, "pointer-events-none");
36
17
  }
37
- var icon = document.createElement("span");
18
+ const icon = document.createElement("span");
38
19
  icon.className = "size-4 flex-shrink-0";
39
20
  icon.innerHTML =
40
21
  '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" class="size-4 flex-shrink-0" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z"/><path d="M14 2v5a1 1 0 0 0 1 1h5"/></svg>';
41
22
  a.appendChild(icon);
42
- var text = document.createElement("span");
23
+ const text = document.createElement("span");
43
24
  text.className = "truncate";
44
25
  text.textContent = title;
45
26
  a.appendChild(text);
46
27
  this.replaceChildren(a);
47
- };
48
- return FileAttachmentElement;
49
- }(HTMLElement));
50
- export { FileAttachmentElement };
28
+ }
29
+ }
@@ -11,7 +11,7 @@ export * from "./inline-math";
11
11
  export * from "./content-reference";
12
12
  export * from "./inline-comment";
13
13
  export * from "./inline-comment-reply";
14
- export var registerWebComponents = function () {
14
+ export const registerWebComponents = () => {
15
15
  if (typeof window !== "undefined" && !customElements.get("page-clipping")) {
16
16
  customElements.define("page-clipping", PageClippingElement);
17
17
  }
@@ -1,25 +1,4 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var InlineCommentReplyElement = /** @class */ (function (_super) {
18
- __extends(InlineCommentReplyElement, _super);
19
- function InlineCommentReplyElement() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- InlineCommentReplyElement.prototype.connectedCallback = function () { };
23
- return InlineCommentReplyElement;
24
- }(HTMLElement));
25
- export { InlineCommentReplyElement };
2
+ export class InlineCommentReplyElement extends HTMLElement {
3
+ connectedCallback() { }
4
+ }
@@ -1,25 +1,4 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var InlineCommentElement = /** @class */ (function (_super) {
18
- __extends(InlineCommentElement, _super);
19
- function InlineCommentElement() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- InlineCommentElement.prototype.connectedCallback = function () { };
23
- return InlineCommentElement;
24
- }(HTMLElement));
25
- export { InlineCommentElement };
2
+ export class InlineCommentElement extends HTMLElement {
3
+ connectedCallback() { }
4
+ }
@@ -1,53 +1,31 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
2
  import { convertLatexToMathMl } from "mathlive";
18
3
  // Custom element for use in rich text editors
19
- var InlineMathElement = /** @class */ (function (_super) {
20
- __extends(InlineMathElement, _super);
21
- function InlineMathElement() {
22
- return _super !== null && _super.apply(this, arguments) || this;
23
- }
24
- InlineMathElement.prototype.connectedCallback = function () {
25
- var _this = this;
4
+ export class InlineMathElement extends HTMLElement {
5
+ observer;
6
+ connectedCallback() {
26
7
  this.render();
27
8
  // Watch for changes to textContent
28
- this.observer = new MutationObserver(function () {
29
- _this.render();
9
+ this.observer = new MutationObserver(() => {
10
+ this.render();
30
11
  });
31
12
  this.observer.observe(this, {
32
13
  childList: true,
33
14
  characterData: true,
34
15
  subtree: true,
35
16
  });
36
- };
37
- InlineMathElement.prototype.disconnectedCallback = function () {
38
- var _a;
39
- (_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
40
- };
41
- InlineMathElement.prototype.render = function () {
42
- var latex = this.textContent;
17
+ }
18
+ disconnectedCallback() {
19
+ this.observer?.disconnect();
20
+ }
21
+ render() {
22
+ const latex = this.textContent;
43
23
  try {
44
- this.innerHTML = "<math>".concat(convertLatexToMathMl(latex), "</math>");
24
+ this.innerHTML = `<math>${convertLatexToMathMl(latex)}</math>`;
45
25
  }
46
26
  catch (error) {
47
27
  this.textContent = error.message;
48
28
  this.style.color = "red";
49
29
  }
50
- };
51
- return InlineMathElement;
52
- }(HTMLElement));
53
- export { InlineMathElement };
30
+ }
31
+ }
@@ -1,37 +1,16 @@
1
1
  "use client";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var PageClippingElement = /** @class */ (function (_super) {
18
- __extends(PageClippingElement, _super);
19
- function PageClippingElement() {
20
- return _super !== null && _super.apply(this, arguments) || this;
21
- }
22
- PageClippingElement.prototype.connectedCallback = function () {
23
- var url = this.getAttribute("url") || "";
24
- var page = this.getAttribute("page") || "";
25
- var x = this.getAttribute("x") || "";
26
- var y = this.getAttribute("y") || "";
27
- var width = this.getAttribute("width") || "";
28
- var height = this.getAttribute("height") || "";
29
- var params = new URLSearchParams({ url: url, page: page, x: x, y: y, width: width, height: height });
30
- var img = document.createElement("img");
31
- img.src = "https://page-clippings.examplary.ai/?".concat(params.toString());
2
+ export class PageClippingElement extends HTMLElement {
3
+ connectedCallback() {
4
+ const url = this.getAttribute("url") || "";
5
+ const page = this.getAttribute("page") || "";
6
+ const x = this.getAttribute("x") || "";
7
+ const y = this.getAttribute("y") || "";
8
+ const width = this.getAttribute("width") || "";
9
+ const height = this.getAttribute("height") || "";
10
+ const params = new URLSearchParams({ url, page, x, y, width, height });
11
+ const img = document.createElement("img");
12
+ img.src = `https://page-clippings.examplary.ai/?${params.toString()}`;
32
13
  img.alt = "Page clipping";
33
14
  this.replaceChildren(img);
34
- };
35
- return PageClippingElement;
36
- }(HTMLElement));
37
- export { PageClippingElement };
15
+ }
16
+ }