@luscii-healthtech/web-ui 54.6.0 → 54.7.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.development.js +28 -9
- package/dist/index.development.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/components/TextEditor/TextEditor.d.ts +16 -0
- package/dist/src/components/TextEditor/mentionSuggestion.d.ts +5 -1
- package/dist/src/generated/components/TextEditor/TextEditor.d.ts +16 -0
- package/dist/src/generated/components/TextEditor/mentionSuggestion.d.ts +5 -1
- package/dist/stories/TextEditor.stories.d.ts +13 -4
- package/dist/web-ui-tailwind.css +208 -0
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +1 -1
|
@@ -5296,7 +5296,7 @@ const MentionList = React.forwardRef(({ items, command }, ref) => {
|
|
|
5296
5296
|
MentionList.displayName = "MentionList";
|
|
5297
5297
|
|
|
5298
5298
|
const MAX_RESULTS = 8;
|
|
5299
|
-
const createMentionSuggestion = (getTags) => ({
|
|
5299
|
+
const createMentionSuggestion = (getTags, getPopupContainer = () => null) => ({
|
|
5300
5300
|
items: ({ query }) => {
|
|
5301
5301
|
const normalizedQuery = query.toLowerCase();
|
|
5302
5302
|
return getTags().filter((tag) => tag.label.toLowerCase().includes(normalizedQuery)).slice(0, MAX_RESULTS);
|
|
@@ -5304,7 +5304,10 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5304
5304
|
render: () => {
|
|
5305
5305
|
let component = null;
|
|
5306
5306
|
let popup = null;
|
|
5307
|
+
let latestClientRect = null;
|
|
5308
|
+
let mountTarget = document.body;
|
|
5307
5309
|
const reposition = (clientRect) => {
|
|
5310
|
+
latestClientRect = clientRect;
|
|
5308
5311
|
if (!popup || !clientRect) {
|
|
5309
5312
|
return;
|
|
5310
5313
|
}
|
|
@@ -5312,11 +5315,14 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5312
5315
|
if (!rect) {
|
|
5313
5316
|
return;
|
|
5314
5317
|
}
|
|
5315
|
-
|
|
5316
|
-
popup.style.
|
|
5318
|
+
const originRect = mountTarget.getBoundingClientRect();
|
|
5319
|
+
popup.style.top = `${rect.bottom - originRect.top + 4}px`;
|
|
5320
|
+
popup.style.left = `${rect.left - originRect.left}px`;
|
|
5317
5321
|
};
|
|
5322
|
+
const handleViewportChange = () => reposition(latestClientRect);
|
|
5318
5323
|
return {
|
|
5319
5324
|
onStart: (props) => {
|
|
5325
|
+
var _a, _b;
|
|
5320
5326
|
component = new react.ReactRenderer(MentionList, {
|
|
5321
5327
|
props,
|
|
5322
5328
|
editor: props.editor
|
|
@@ -5324,12 +5330,15 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5324
5330
|
if (!props.clientRect) {
|
|
5325
5331
|
return;
|
|
5326
5332
|
}
|
|
5333
|
+
mountTarget = (_b = (_a = getPopupContainer()) !== null && _a !== void 0 ? _a : props.editor.view.dom.closest("dialog")) !== null && _b !== void 0 ? _b : document.body;
|
|
5327
5334
|
popup = document.createElement("div");
|
|
5328
|
-
popup.style.position = "
|
|
5335
|
+
popup.style.position = "absolute";
|
|
5329
5336
|
popup.style.zIndex = "1000";
|
|
5330
5337
|
popup.appendChild(component.element);
|
|
5331
|
-
|
|
5338
|
+
mountTarget.appendChild(popup);
|
|
5332
5339
|
reposition(props.clientRect);
|
|
5340
|
+
window.addEventListener("scroll", handleViewportChange, true);
|
|
5341
|
+
window.addEventListener("resize", handleViewportChange);
|
|
5333
5342
|
},
|
|
5334
5343
|
onUpdate: (props) => {
|
|
5335
5344
|
component === null || component === void 0 ? void 0 : component.updateProps(props);
|
|
@@ -5340,6 +5349,9 @@ const createMentionSuggestion = (getTags) => ({
|
|
|
5340
5349
|
return (_b = (_a = component === null || component === void 0 ? void 0 : component.ref) === null || _a === void 0 ? void 0 : _a.onKeyDown(props)) !== null && _b !== void 0 ? _b : false;
|
|
5341
5350
|
},
|
|
5342
5351
|
onExit: () => {
|
|
5352
|
+
window.removeEventListener("scroll", handleViewportChange, true);
|
|
5353
|
+
window.removeEventListener("resize", handleViewportChange);
|
|
5354
|
+
latestClientRect = null;
|
|
5343
5355
|
popup === null || popup === void 0 ? void 0 : popup.remove();
|
|
5344
5356
|
popup = null;
|
|
5345
5357
|
component === null || component === void 0 ? void 0 : component.destroy();
|
|
@@ -5356,8 +5368,13 @@ const MentionView = ({ node }) => {
|
|
|
5356
5368
|
const char = (_b = node.attrs.mentionSuggestionChar) !== null && _b !== void 0 ? _b : "@";
|
|
5357
5369
|
const display = `${char}${label}`;
|
|
5358
5370
|
const tooltipText = id && id !== label ? id : null;
|
|
5359
|
-
const
|
|
5360
|
-
|
|
5371
|
+
const [dialogContainer, setDialogContainer] = React.useState(null);
|
|
5372
|
+
const pillRef = React.useCallback((el) => {
|
|
5373
|
+
var _a2;
|
|
5374
|
+
setDialogContainer((_a2 = el === null || el === void 0 ? void 0 : el.closest("dialog")) !== null && _a2 !== void 0 ? _a2 : null);
|
|
5375
|
+
}, []);
|
|
5376
|
+
const pill = jsxRuntime.jsx("span", { ref: pillRef, className: "web-ui-mention", children: display });
|
|
5377
|
+
return jsxRuntime.jsx(react.NodeViewWrapper, { as: "span", children: tooltipText ? jsxRuntime.jsx(Tooltip$1.Provider, { children: jsxRuntime.jsxs(Tooltip.Root, { children: [jsxRuntime.jsx(Tooltip.Trigger, { asChild: true, children: pill }), jsxRuntime.jsx(Tooltip.Content, { container: dialogContainer !== null && dialogContainer !== void 0 ? dialogContainer : void 0, children: jsxRuntime.jsx(Tooltip.Text, { children: tooltipText }) })] }) }) : pill });
|
|
5361
5378
|
};
|
|
5362
5379
|
|
|
5363
5380
|
const TEXT_EDITOR_TRANSLATIONS = {
|
|
@@ -5472,12 +5489,13 @@ const TextEditor = (_a) => {
|
|
|
5472
5489
|
["bold", "italic", "underline", "strike"],
|
|
5473
5490
|
[{ list: "ordered" }, { list: "bullet" }],
|
|
5474
5491
|
["link"]
|
|
5475
|
-
], placeholder, tags, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "tags", "onValueChange"]);
|
|
5492
|
+
], placeholder, tags, popupContainer, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "tags", "popupContainer", "onValueChange"]);
|
|
5476
5493
|
const rawId = React.useId();
|
|
5477
5494
|
const toolbarId = `toolbar-${rawId.replace(/:/g, "")}`;
|
|
5478
5495
|
const defaultValueRef = React.useRef(sanitize(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""));
|
|
5479
5496
|
const onTextChangeRef = React.useRef(onValueChange);
|
|
5480
5497
|
const tagsRef = React.useRef(tags !== null && tags !== void 0 ? tags : []);
|
|
5498
|
+
const popupContainerRef = React.useRef(popupContainer);
|
|
5481
5499
|
const mentionsEnabled = tags !== void 0;
|
|
5482
5500
|
const [linkTooltip, setLinkTooltip] = React.useState(null);
|
|
5483
5501
|
const [hasTextSelected, setHasTextSelected] = React.useState(false);
|
|
@@ -5486,6 +5504,7 @@ const TextEditor = (_a) => {
|
|
|
5486
5504
|
React.useLayoutEffect(() => {
|
|
5487
5505
|
onTextChangeRef.current = onValueChange;
|
|
5488
5506
|
tagsRef.current = tags !== null && tags !== void 0 ? tags : [];
|
|
5507
|
+
popupContainerRef.current = popupContainer;
|
|
5489
5508
|
});
|
|
5490
5509
|
const editor = react.useEditor({
|
|
5491
5510
|
extensions: [
|
|
@@ -5516,7 +5535,7 @@ const TextEditor = (_a) => {
|
|
|
5516
5535
|
...mentionsEnabled ? [
|
|
5517
5536
|
MentionWithTooltip.configure({
|
|
5518
5537
|
HTMLAttributes: { class: "web-ui-mention" },
|
|
5519
|
-
suggestion: createMentionSuggestion(() => tagsRef.current)
|
|
5538
|
+
suggestion: createMentionSuggestion(() => tagsRef.current, () => popupContainerRef.current)
|
|
5520
5539
|
})
|
|
5521
5540
|
] : []
|
|
5522
5541
|
],
|