@examplary/ui 1.47.0 → 1.49.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/README.md +1 -1
- package/dist/components/rich-text/index.d.ts +2 -1
- package/dist/components/rich-text/index.js +2 -1
- package/dist/components/rich-text/minimal-rich-text-field.d.ts +7 -2
- package/dist/components/rich-text/minimal-rich-text-field.js +53 -34
- package/dist/components/rich-text/tiptap/collaboration-caret.d.ts +25 -0
- package/dist/components/rich-text/tiptap/collaboration-caret.js +81 -0
- package/dist/components/rich-text/tiptap/content-reference.d.ts +3 -0
- package/dist/components/rich-text/tiptap/content-reference.js +25 -0
- package/dist/components/rich-text/tiptap/extensions.d.ts +2 -0
- package/dist/components/rich-text/tiptap/extensions.js +43 -0
- package/dist/components/rich-text/tiptap/file-attachment.js +38 -14
- package/dist/components/rich-text/tiptap/image.d.ts +0 -19
- package/dist/components/rich-text/tiptap/mathematics-component.js +2 -2
- package/dist/components/rich-text/tiptap/mathematics.js +1 -1
- package/dist/components/rich-text/tiptap/page-clipping.js +0 -26
- package/dist/components/rich-text/tiptap/rich-text-formatting-menu.js +35 -27
- package/dist/components/ui/badge.d.ts +1 -1
- package/dist/components/ui/badge.js +1 -0
- package/dist/components/ui/button.js +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/web-components/content-reference.d.ts +11 -0
- package/dist/components/web-components/content-reference.js +111 -0
- package/dist/components/web-components/file-attachment.d.ts +0 -9
- package/dist/components/web-components/file-attachment.js +20 -11
- package/dist/components/web-components/index.d.ts +1 -0
- package/dist/components/web-components/index.js +6 -0
- package/dist/components/web-components/page-clipping.d.ts +0 -1
- package/dist/components/web-components/page-clipping.js +5 -9
- package/dist/src/global.css +1 -1
- package/package.json +9 -4
- package/src/global.css +59 -0
|
@@ -25,7 +25,7 @@ import * as React from "react";
|
|
|
25
25
|
import { Slot } from "@radix-ui/react-slot";
|
|
26
26
|
import { cva } from "class-variance-authority";
|
|
27
27
|
import { cn } from "../../utils";
|
|
28
|
-
var buttonVariants = cva("inline-flex items-center text-text dark:text-white cursor-pointer justify-center whitespace-nowrap rounded-full font-base ring-offset-white transition-all gap-1.5 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black/20 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", {
|
|
28
|
+
var buttonVariants = cva("inline-flex items-center select-none text-text dark:text-white cursor-pointer justify-center whitespace-nowrap rounded-full font-base ring-offset-white transition-all gap-1.5 [&_svg]:pointer-events-none [&_svg]:size-4 [&_svg]:shrink-0 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-black/20 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50", {
|
|
29
29
|
variants: {
|
|
30
30
|
variant: {
|
|
31
31
|
default: "bg-nav border border-black dark:bg-zinc-800 dark:border-white hover:shadow-light",
|
|
@@ -24,7 +24,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
24
24
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
25
25
|
import * as React from "react";
|
|
26
26
|
import * as PopoverPrimitive from "@radix-ui/react-popover";
|
|
27
|
-
import { cn } from "../../utils";
|
|
27
|
+
import { cn } from "../../utils.js";
|
|
28
28
|
export var Popover = PopoverPrimitive.Root;
|
|
29
29
|
export var PopoverTrigger = PopoverPrimitive.Trigger;
|
|
30
30
|
export var PopoverContent = React.forwardRef(function (_a, ref) {
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class ContentReferenceElement extends HTMLElement {
|
|
2
|
+
private targetEl;
|
|
3
|
+
connectedCallback(): void;
|
|
4
|
+
disconnectedCallback(): void;
|
|
5
|
+
private timeout;
|
|
6
|
+
private handleClick;
|
|
7
|
+
private handleKeyDown;
|
|
8
|
+
private handleEnter;
|
|
9
|
+
private handleLeave;
|
|
10
|
+
private restore;
|
|
11
|
+
}
|
|
@@ -0,0 +1,111 @@
|
|
|
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
|
+
_this.handleEnter();
|
|
25
|
+
if (_this.timeout)
|
|
26
|
+
clearTimeout(_this.timeout);
|
|
27
|
+
_this.timeout = setTimeout(function () {
|
|
28
|
+
_this.timeout = null;
|
|
29
|
+
_this.restore();
|
|
30
|
+
}, 2000);
|
|
31
|
+
};
|
|
32
|
+
_this.handleKeyDown = function (event) {
|
|
33
|
+
if (event.key !== "Enter" && event.key !== " ")
|
|
34
|
+
return;
|
|
35
|
+
event.preventDefault();
|
|
36
|
+
_this.handleClick();
|
|
37
|
+
};
|
|
38
|
+
_this.handleEnter = function () {
|
|
39
|
+
if (_this.targetEl)
|
|
40
|
+
return;
|
|
41
|
+
var parent = _this.closest("[data-content-reference-target]");
|
|
42
|
+
var targetId = parent === null || parent === void 0 ? void 0 : parent.dataset.contentReferenceTarget;
|
|
43
|
+
if (!targetId)
|
|
44
|
+
return;
|
|
45
|
+
var target = document.getElementById(targetId);
|
|
46
|
+
if (!target)
|
|
47
|
+
return;
|
|
48
|
+
var quote = _this.getAttribute("quote");
|
|
49
|
+
if (!quote)
|
|
50
|
+
return;
|
|
51
|
+
var html = target.innerHTML;
|
|
52
|
+
if (!html.includes(quote))
|
|
53
|
+
return;
|
|
54
|
+
_this.targetEl = target;
|
|
55
|
+
target.innerHTML = html.replace(quote, "<mark class=\"content-reference-highlight\">".concat(quote, "</mark>"));
|
|
56
|
+
};
|
|
57
|
+
_this.handleLeave = function () {
|
|
58
|
+
if (_this.timeout)
|
|
59
|
+
return;
|
|
60
|
+
_this.restore();
|
|
61
|
+
};
|
|
62
|
+
return _this;
|
|
63
|
+
}
|
|
64
|
+
ContentReferenceElement.prototype.connectedCallback = function () {
|
|
65
|
+
if (!this.hasAttribute("tabindex"))
|
|
66
|
+
this.tabIndex = 0;
|
|
67
|
+
if (!this.hasAttribute("role"))
|
|
68
|
+
this.setAttribute("role", "button");
|
|
69
|
+
if (!this.hasAttribute("aria-label")) {
|
|
70
|
+
this.setAttribute("aria-label", this.getAttribute("quote") || "Content reference");
|
|
71
|
+
}
|
|
72
|
+
this.addEventListener("mouseenter", this.handleEnter);
|
|
73
|
+
this.addEventListener("mouseleave", this.handleLeave);
|
|
74
|
+
this.addEventListener("click", this.handleClick);
|
|
75
|
+
this.addEventListener("touchstart", this.handleClick);
|
|
76
|
+
this.addEventListener("keydown", this.handleKeyDown);
|
|
77
|
+
this.addEventListener("focus", this.handleEnter);
|
|
78
|
+
this.addEventListener("blur", this.handleLeave);
|
|
79
|
+
};
|
|
80
|
+
ContentReferenceElement.prototype.disconnectedCallback = function () {
|
|
81
|
+
this.removeEventListener("mouseenter", this.handleEnter);
|
|
82
|
+
this.removeEventListener("mouseleave", this.handleLeave);
|
|
83
|
+
this.removeEventListener("click", this.handleClick);
|
|
84
|
+
this.removeEventListener("touchstart", this.handleClick);
|
|
85
|
+
this.removeEventListener("keydown", this.handleKeyDown);
|
|
86
|
+
this.removeEventListener("focus", this.handleEnter);
|
|
87
|
+
this.removeEventListener("blur", this.handleLeave);
|
|
88
|
+
this.restore();
|
|
89
|
+
};
|
|
90
|
+
ContentReferenceElement.prototype.restore = function () {
|
|
91
|
+
if (this.timeout) {
|
|
92
|
+
clearTimeout(this.timeout);
|
|
93
|
+
this.timeout = null;
|
|
94
|
+
}
|
|
95
|
+
if (!this.targetEl)
|
|
96
|
+
return;
|
|
97
|
+
var highlights = this.targetEl.querySelectorAll("mark.content-reference-highlight");
|
|
98
|
+
highlights.forEach(function (highlight) {
|
|
99
|
+
var parent = highlight.parentNode;
|
|
100
|
+
if (!parent)
|
|
101
|
+
return;
|
|
102
|
+
while (highlight.firstChild) {
|
|
103
|
+
parent.insertBefore(highlight.firstChild, highlight);
|
|
104
|
+
}
|
|
105
|
+
parent.removeChild(highlight);
|
|
106
|
+
});
|
|
107
|
+
this.targetEl = null;
|
|
108
|
+
};
|
|
109
|
+
return ContentReferenceElement;
|
|
110
|
+
}(HTMLElement));
|
|
111
|
+
export { ContentReferenceElement };
|
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
interface FileAttachmentProps {
|
|
3
|
-
title: string;
|
|
4
|
-
type?: string;
|
|
5
|
-
href: string;
|
|
6
|
-
className?: string;
|
|
7
|
-
}
|
|
8
|
-
export declare const FileAttachmentView: React.FC<FileAttachmentProps>;
|
|
9
1
|
export declare class FileAttachmentElement extends HTMLElement {
|
|
10
2
|
connectedCallback(): void;
|
|
11
3
|
}
|
|
12
|
-
export {};
|
|
@@ -14,15 +14,7 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
18
|
-
import { FileIcon } from "lucide-react";
|
|
19
|
-
import { createRoot } from "react-dom/client";
|
|
20
17
|
import { cn } from "../../utils";
|
|
21
|
-
export var FileAttachmentView = function (_a) {
|
|
22
|
-
var title = _a.title, href = _a.href, className = _a.className;
|
|
23
|
-
return (_jsxs("a", { href: href, target: "_blank", rel: "noopener noreferrer", className: cn("flex items-center gap-1.5 mt-1.5 py-1 rounded-base text-sm font-medium", className), children: [_jsx(FileIcon, { className: "size-4 flex-shrink-0" }), _jsx("span", { className: "truncate", children: title })] }));
|
|
24
|
-
};
|
|
25
|
-
// Custom element for use in rich text editors
|
|
26
18
|
var FileAttachmentElement = /** @class */ (function (_super) {
|
|
27
19
|
__extends(FileAttachmentElement, _super);
|
|
28
20
|
function FileAttachmentElement() {
|
|
@@ -30,11 +22,28 @@ var FileAttachmentElement = /** @class */ (function (_super) {
|
|
|
30
22
|
}
|
|
31
23
|
FileAttachmentElement.prototype.connectedCallback = function () {
|
|
32
24
|
var title = this.getAttribute("title") || "File";
|
|
33
|
-
var type = this.getAttribute("type") || "";
|
|
34
25
|
var href = this.getAttribute("href") || "#";
|
|
35
26
|
// Create React root and render component
|
|
36
|
-
var
|
|
37
|
-
|
|
27
|
+
var a = document.createElement("a");
|
|
28
|
+
a.href = href;
|
|
29
|
+
a.target = "_blank";
|
|
30
|
+
a.rel = "noopener noreferrer";
|
|
31
|
+
a.className =
|
|
32
|
+
"inline-flex items-center gap-1.5 mt-1.5 py-1 px-2 rounded-lg text-sm no-underline! font-medium max-w-full bg-blue-100/70 hover:bg-blue-100 text-blue-800 transition";
|
|
33
|
+
// If one of the parent elements is .ProseMirror, we want to disable pointer events on the link, since that is annoying in the editor
|
|
34
|
+
if (this.closest(".ProseMirror")) {
|
|
35
|
+
a.className = cn(a.className, "pointer-events-none");
|
|
36
|
+
}
|
|
37
|
+
var icon = document.createElement("span");
|
|
38
|
+
icon.className = "size-4 flex-shrink-0";
|
|
39
|
+
icon.innerHTML =
|
|
40
|
+
'<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
|
+
a.appendChild(icon);
|
|
42
|
+
var text = document.createElement("span");
|
|
43
|
+
text.className = "truncate";
|
|
44
|
+
text.textContent = title;
|
|
45
|
+
a.appendChild(text);
|
|
46
|
+
this.replaceChildren(a);
|
|
38
47
|
};
|
|
39
48
|
return FileAttachmentElement;
|
|
40
49
|
}(HTMLElement));
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
"use client";
|
|
2
|
+
import { ContentReferenceElement } from "./content-reference";
|
|
2
3
|
import { FileAttachmentElement } from "./file-attachment";
|
|
3
4
|
import { InlineMathElement } from "./inline-math";
|
|
4
5
|
import { PageClippingElement } from "./page-clipping";
|
|
5
6
|
export * from "./file-attachment";
|
|
6
7
|
export * from "./page-clipping";
|
|
7
8
|
export * from "./inline-math";
|
|
9
|
+
export * from "./content-reference";
|
|
8
10
|
export var registerWebComponents = function () {
|
|
9
11
|
if (typeof window !== "undefined" && !customElements.get("page-clipping")) {
|
|
10
12
|
customElements.define("page-clipping", PageClippingElement);
|
|
@@ -15,4 +17,8 @@ export var registerWebComponents = function () {
|
|
|
15
17
|
if (typeof window !== "undefined" && !customElements.get("inline-math")) {
|
|
16
18
|
customElements.define("inline-math", InlineMathElement);
|
|
17
19
|
}
|
|
20
|
+
if (typeof window !== "undefined" &&
|
|
21
|
+
!customElements.get("content-reference")) {
|
|
22
|
+
customElements.define("content-reference", ContentReferenceElement);
|
|
23
|
+
}
|
|
18
24
|
};
|
|
@@ -14,12 +14,6 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { createRoot } from "react-dom/client";
|
|
19
|
-
export var PageClippingView = function (props) {
|
|
20
|
-
return (_jsx("img", { src: "https://page-clippings.examplary.ai/?".concat(new URLSearchParams(props)), alt: "Page Clipping" }));
|
|
21
|
-
};
|
|
22
|
-
// Custom element for use in rich text editors
|
|
23
17
|
var PageClippingElement = /** @class */ (function (_super) {
|
|
24
18
|
__extends(PageClippingElement, _super);
|
|
25
19
|
function PageClippingElement() {
|
|
@@ -32,9 +26,11 @@ var PageClippingElement = /** @class */ (function (_super) {
|
|
|
32
26
|
var y = this.getAttribute("y") || "";
|
|
33
27
|
var width = this.getAttribute("width") || "";
|
|
34
28
|
var height = this.getAttribute("height") || "";
|
|
35
|
-
|
|
36
|
-
var
|
|
37
|
-
|
|
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());
|
|
32
|
+
img.alt = "Page clipping";
|
|
33
|
+
this.replaceChildren(img);
|
|
38
34
|
};
|
|
39
35
|
return PageClippingElement;
|
|
40
36
|
}(HTMLElement));
|