@luscii-healthtech/web-ui 51.4.0 → 52.0.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 +199 -79
- 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/LinkTooltip.d.ts +4 -2
- package/dist/src/components/TextEditor/TextEditor.d.ts +5 -10
- package/dist/src/components/TextEditor/TextEditorToolbar.d.ts +5 -1
- package/dist/src/components/TextEditor/TextEditorToolbarButton.d.ts +4 -0
- package/dist/src/components/TextEditor/textEditorTranslations.d.ts +17 -0
- package/dist/src/generated/components/TextEditor/LinkTooltip.d.ts +4 -2
- package/dist/src/generated/components/TextEditor/TextEditor.d.ts +5 -10
- package/dist/src/generated/components/TextEditor/TextEditorToolbar.d.ts +5 -1
- package/dist/src/generated/components/TextEditor/TextEditorToolbarButton.d.ts +4 -0
- package/dist/src/generated/components/TextEditor/textEditorTranslations.d.ts +17 -0
- package/dist/src/generated/index.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/stories/TextEditor.stories.d.ts +2 -2
- package/dist/web-ui.esm.js +1 -1
- package/dist/web-ui.esm.js.map +1 -1
- package/package.json +4 -3
|
@@ -26,10 +26,10 @@ var TabsPrimitive = require('@radix-ui/react-tabs');
|
|
|
26
26
|
var PropTypes = require('prop-types');
|
|
27
27
|
var ReactSelect = require('react-select');
|
|
28
28
|
var RadixSwitch = require('@radix-ui/react-switch');
|
|
29
|
-
var
|
|
30
|
-
require('
|
|
29
|
+
var react = require('@tiptap/react');
|
|
30
|
+
var StarterKit = require('@tiptap/starter-kit');
|
|
31
31
|
var solid = require('@heroicons/react/20/solid');
|
|
32
|
-
var react = require('@headlessui/react');
|
|
32
|
+
var react$1 = require('@headlessui/react');
|
|
33
33
|
var ToggleGroup = require('@radix-ui/react-toggle-group');
|
|
34
34
|
var d3 = require('d3-scale');
|
|
35
35
|
|
|
@@ -65,7 +65,7 @@ var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
|
|
|
65
65
|
var PropTypes__default = /*#__PURE__*/_interopDefault(PropTypes);
|
|
66
66
|
var ReactSelect__default = /*#__PURE__*/_interopDefault(ReactSelect);
|
|
67
67
|
var RadixSwitch__namespace = /*#__PURE__*/_interopNamespace(RadixSwitch);
|
|
68
|
-
var
|
|
68
|
+
var StarterKit__default = /*#__PURE__*/_interopDefault(StarterKit);
|
|
69
69
|
var ToggleGroup__namespace = /*#__PURE__*/_interopNamespace(ToggleGroup);
|
|
70
70
|
var d3__namespace = /*#__PURE__*/_interopNamespace(d3);
|
|
71
71
|
|
|
@@ -5041,7 +5041,7 @@ const Textarea = React__namespace.default.forwardRef((_a, ref) => {
|
|
|
5041
5041
|
]), style, ref }));
|
|
5042
5042
|
});
|
|
5043
5043
|
|
|
5044
|
-
const LinkTooltip = ({ linkElement,
|
|
5044
|
+
const LinkTooltip = ({ linkElement, editorInstance, onClose, translations }) => {
|
|
5045
5045
|
const dialogRef = React.useRef(null);
|
|
5046
5046
|
const anchorName = React.useRef(`link-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`);
|
|
5047
5047
|
React.useEffect(() => {
|
|
@@ -5069,25 +5069,23 @@ const LinkTooltip = ({ linkElement, quillInstance, onClose }) => {
|
|
|
5069
5069
|
}, [linkElement, onClose]);
|
|
5070
5070
|
const handleEditLink = () => {
|
|
5071
5071
|
const currentUrl = linkElement.getAttribute("href") || "";
|
|
5072
|
-
const newUrl = prompt(
|
|
5072
|
+
const newUrl = prompt(translations.linkUrlPrompt, currentUrl);
|
|
5073
5073
|
if (newUrl !== null) {
|
|
5074
|
-
const
|
|
5075
|
-
|
|
5076
|
-
|
|
5077
|
-
|
|
5078
|
-
|
|
5079
|
-
quillInstance.format("link", newUrl || false);
|
|
5074
|
+
const { view } = editorInstance;
|
|
5075
|
+
const pos = view.posAtDOM(linkElement, 0);
|
|
5076
|
+
const node = view.state.doc.nodeAt(pos);
|
|
5077
|
+
if (node) {
|
|
5078
|
+
editorInstance.chain().focus().setTextSelection({ from: pos, to: pos + node.nodeSize }).setLink({ href: newUrl || "" }).run();
|
|
5080
5079
|
}
|
|
5081
5080
|
}
|
|
5082
5081
|
onClose();
|
|
5083
5082
|
};
|
|
5084
5083
|
const handleRemoveLink = () => {
|
|
5085
|
-
const
|
|
5086
|
-
|
|
5087
|
-
|
|
5088
|
-
|
|
5089
|
-
|
|
5090
|
-
quillInstance.format("link", false);
|
|
5084
|
+
const { view } = editorInstance;
|
|
5085
|
+
const pos = view.posAtDOM(linkElement, 0);
|
|
5086
|
+
const node = view.state.doc.nodeAt(pos);
|
|
5087
|
+
if (node) {
|
|
5088
|
+
editorInstance.chain().focus().setTextSelection({ from: pos, to: pos + node.nodeSize }).unsetLink().run();
|
|
5091
5089
|
}
|
|
5092
5090
|
onClose();
|
|
5093
5091
|
};
|
|
@@ -5099,33 +5097,57 @@ const LinkTooltip = ({ linkElement, quillInstance, onClose }) => {
|
|
|
5099
5097
|
top: "anchor(bottom)",
|
|
5100
5098
|
left: "anchor(left)",
|
|
5101
5099
|
marginTop: "8px"
|
|
5102
|
-
}, children: jsxRuntime.jsx(Card, { borderRadius: "s", elevation: "large", className: "ui:max-w-80", padding: false, border: true, children: jsxRuntime.jsxs(Stack, { width: "full", align: "stretch", children: [jsxRuntime.jsx(Box, { p: "xs", children: jsxRuntime.jsxs(Text, { children: [
|
|
5100
|
+
}, children: jsxRuntime.jsx(Card, { borderRadius: "s", elevation: "large", className: "ui:max-w-80", padding: false, border: true, children: jsxRuntime.jsxs(Stack, { width: "full", align: "stretch", children: [jsxRuntime.jsx(Box, { p: "xs", children: jsxRuntime.jsxs(Text, { children: [translations.visitUrlLabel, " ", jsxRuntime.jsx("a", { href: url, target: "_blank", rel: "noopener noreferrer", className: "ui:text-blue-600 ui:underline ui:text-sm ui:overflow-hidden ui:text-ellipsis ui:whitespace-nowrap hover:ui:text-blue-700", children: url })] }) }), jsxRuntime.jsx(Divider, { version: "v2" }), jsxRuntime.jsxs(Stack, { axis: "x", gap: "xxs", p: "xs", children: [jsxRuntime.jsx(TertiaryButton, { onClick: handleEditLink, text: translations.editButtonText, size: "medium" }), jsxRuntime.jsx(TertiaryButton, { onClick: handleRemoveLink, text: translations.removeButtonText, size: "medium" }), jsxRuntime.jsx(TertiaryButton, { onClick: onClose, text: translations.closeButtonText, size: "medium" })] })] }) }) });
|
|
5103
5101
|
};
|
|
5104
5102
|
|
|
5105
|
-
const TextEditorToolbarButton = ({ option, hasTextSelected }) => {
|
|
5103
|
+
const TextEditorToolbarButton = ({ option, hasTextSelected, editor, translations }) => {
|
|
5104
|
+
const [, forceUpdate] = React.useState(0);
|
|
5105
|
+
React.useEffect(() => {
|
|
5106
|
+
if (!editor) {
|
|
5107
|
+
return void 0;
|
|
5108
|
+
}
|
|
5109
|
+
const handleUpdate = () => {
|
|
5110
|
+
forceUpdate((n) => n + 1);
|
|
5111
|
+
};
|
|
5112
|
+
editor.on("transaction", handleUpdate);
|
|
5113
|
+
editor.on("selectionUpdate", handleUpdate);
|
|
5114
|
+
return () => {
|
|
5115
|
+
editor.off("transaction", handleUpdate);
|
|
5116
|
+
editor.off("selectionUpdate", handleUpdate);
|
|
5117
|
+
};
|
|
5118
|
+
}, [editor]);
|
|
5106
5119
|
const buttonClasses = "ui:aria-pressed:bg-primary-background ui:aria-disabled:cursor-not-allowed";
|
|
5120
|
+
if (!editor) {
|
|
5121
|
+
return null;
|
|
5122
|
+
}
|
|
5107
5123
|
if (typeof option === "string") {
|
|
5108
5124
|
switch (option) {
|
|
5109
5125
|
case "bold":
|
|
5110
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5126
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.boldLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleBold().run(), "aria-pressed": editor.isActive("bold"), children: jsxRuntime.jsx(solid.BoldIcon, { width: 16 }) });
|
|
5111
5127
|
case "italic":
|
|
5112
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5128
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.italicLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleItalic().run(), "aria-pressed": editor.isActive("italic"), children: jsxRuntime.jsx(solid.ItalicIcon, { width: 16 }) });
|
|
5113
5129
|
case "underline":
|
|
5114
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5130
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.underlineLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleUnderline().run(), "aria-pressed": editor.isActive("underline"), children: jsxRuntime.jsx(solid.UnderlineIcon, { width: 16 }) });
|
|
5115
5131
|
case "strike":
|
|
5116
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5132
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.strikeLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleStrike().run(), "aria-pressed": editor.isActive("strike"), children: jsxRuntime.jsx(solid.StrikethroughIcon, { width: 16 }) });
|
|
5117
5133
|
case "link":
|
|
5118
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5119
|
-
|
|
5120
|
-
|
|
5134
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.linkLabel, className: buttonClasses, disabled: !hasTextSelected, onClick: () => {
|
|
5135
|
+
if (!hasTextSelected) {
|
|
5136
|
+
return;
|
|
5137
|
+
}
|
|
5138
|
+
const url = prompt(translations.enterUrlPrompt);
|
|
5139
|
+
if (url) {
|
|
5140
|
+
editor.chain().focus().extendMarkRange("link").setLink({ href: url }).run();
|
|
5141
|
+
}
|
|
5142
|
+
}, "aria-pressed": editor.isActive("link"), children: jsxRuntime.jsx(solid.LinkIcon, { width: 16 }) });
|
|
5121
5143
|
default:
|
|
5122
5144
|
return null;
|
|
5123
5145
|
}
|
|
5124
5146
|
} else if (typeof option === "object" && "list" in option) {
|
|
5125
5147
|
if (option.list === "ordered") {
|
|
5126
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5148
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.orderedListLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleOrderedList().run(), "aria-pressed": editor.isActive("orderedList"), children: jsxRuntime.jsx(solid.NumberedListIcon, { width: 16 }) });
|
|
5127
5149
|
} else if (option.list === "bullet") {
|
|
5128
|
-
return jsxRuntime.jsx(TertiaryIconButton, { label:
|
|
5150
|
+
return jsxRuntime.jsx(TertiaryIconButton, { label: translations.bulletListLabel, className: buttonClasses, onClick: () => editor.chain().focus().toggleBulletList().run(), "aria-pressed": editor.isActive("bulletList"), children: jsxRuntime.jsx(solid.ListBulletIcon, { width: 16 }) });
|
|
5129
5151
|
}
|
|
5130
5152
|
}
|
|
5131
5153
|
return null;
|
|
@@ -5149,11 +5171,92 @@ const getGroupKey = (group) => {
|
|
|
5149
5171
|
return "";
|
|
5150
5172
|
}).join("-");
|
|
5151
5173
|
};
|
|
5152
|
-
const TextEditorToolbar = ({ toolbarId, toolbar, hasTextSelected }) => {
|
|
5153
|
-
return jsxRuntime.jsx(Stack, { axis: "x", gap: "m",
|
|
5174
|
+
const TextEditorToolbar = ({ toolbarId, toolbar, hasTextSelected, editor, translations }) => {
|
|
5175
|
+
return jsxRuntime.jsx(Stack, { axis: "x", gap: "m", _px: "xs", id: toolbarId, children: toolbar.map((group) => jsxRuntime.jsx(Stack, { axis: "x", _gap: "xs", children: group.map((option, optionIndex) => jsxRuntime.jsx(TextEditorToolbarButton, { option, hasTextSelected, editor, translations }, getOptionKey(option, optionIndex))) }, getGroupKey(group))) });
|
|
5176
|
+
};
|
|
5177
|
+
|
|
5178
|
+
const TEXT_EDITOR_TRANSLATIONS = {
|
|
5179
|
+
"en-GB": {
|
|
5180
|
+
boldLabel: "bold",
|
|
5181
|
+
italicLabel: "italic",
|
|
5182
|
+
underlineLabel: "underline",
|
|
5183
|
+
strikeLabel: "strike",
|
|
5184
|
+
linkLabel: "link",
|
|
5185
|
+
orderedListLabel: "ordered list",
|
|
5186
|
+
bulletListLabel: "bullet list",
|
|
5187
|
+
enterUrlPrompt: "Enter URL:",
|
|
5188
|
+
linkUrlPrompt: "Link URL:",
|
|
5189
|
+
visitUrlLabel: "Visit URL:",
|
|
5190
|
+
editButtonText: "Edit",
|
|
5191
|
+
removeButtonText: "Remove",
|
|
5192
|
+
closeButtonText: "Close"
|
|
5193
|
+
},
|
|
5194
|
+
"nl-NL": {
|
|
5195
|
+
boldLabel: "vetgedrukt",
|
|
5196
|
+
italicLabel: "cursief",
|
|
5197
|
+
underlineLabel: "onderstreept",
|
|
5198
|
+
strikeLabel: "doorgestreept",
|
|
5199
|
+
linkLabel: "link",
|
|
5200
|
+
orderedListLabel: "genummerde lijst",
|
|
5201
|
+
bulletListLabel: "opsommingslijst",
|
|
5202
|
+
enterUrlPrompt: "Voer URL in:",
|
|
5203
|
+
linkUrlPrompt: "Link URL:",
|
|
5204
|
+
visitUrlLabel: "Bezoek URL:",
|
|
5205
|
+
editButtonText: "Bewerken",
|
|
5206
|
+
removeButtonText: "Verwijderen",
|
|
5207
|
+
closeButtonText: "Sluiten"
|
|
5208
|
+
},
|
|
5209
|
+
"de-DE": {
|
|
5210
|
+
boldLabel: "fett",
|
|
5211
|
+
italicLabel: "kursiv",
|
|
5212
|
+
underlineLabel: "unterstrichen",
|
|
5213
|
+
strikeLabel: "durchgestrichen",
|
|
5214
|
+
linkLabel: "Link",
|
|
5215
|
+
orderedListLabel: "nummerierte Liste",
|
|
5216
|
+
bulletListLabel: "Aufz\xE4hlungsliste",
|
|
5217
|
+
enterUrlPrompt: "URL eingeben:",
|
|
5218
|
+
linkUrlPrompt: "Link-URL:",
|
|
5219
|
+
visitUrlLabel: "URL besuchen:",
|
|
5220
|
+
editButtonText: "Bearbeiten",
|
|
5221
|
+
removeButtonText: "Entfernen",
|
|
5222
|
+
closeButtonText: "Schlie\xDFen"
|
|
5223
|
+
},
|
|
5224
|
+
"fr-FR": {
|
|
5225
|
+
boldLabel: "gras",
|
|
5226
|
+
italicLabel: "italique",
|
|
5227
|
+
underlineLabel: "soulign\xE9",
|
|
5228
|
+
strikeLabel: "barr\xE9",
|
|
5229
|
+
linkLabel: "lien",
|
|
5230
|
+
orderedListLabel: "liste num\xE9rot\xE9e",
|
|
5231
|
+
bulletListLabel: "liste \xE0 puces",
|
|
5232
|
+
enterUrlPrompt: "Entrer l'URL :",
|
|
5233
|
+
linkUrlPrompt: "URL du lien :",
|
|
5234
|
+
visitUrlLabel: "Visiter l'URL :",
|
|
5235
|
+
editButtonText: "Modifier",
|
|
5236
|
+
removeButtonText: "Supprimer",
|
|
5237
|
+
closeButtonText: "Fermer"
|
|
5238
|
+
},
|
|
5239
|
+
"pt-PT": {
|
|
5240
|
+
boldLabel: "negrito",
|
|
5241
|
+
italicLabel: "it\xE1lico",
|
|
5242
|
+
underlineLabel: "sublinhado",
|
|
5243
|
+
strikeLabel: "riscado",
|
|
5244
|
+
linkLabel: "liga\xE7\xE3o",
|
|
5245
|
+
orderedListLabel: "lista numerada",
|
|
5246
|
+
bulletListLabel: "lista com marcadores",
|
|
5247
|
+
enterUrlPrompt: "Introduzir URL:",
|
|
5248
|
+
linkUrlPrompt: "URL da liga\xE7\xE3o:",
|
|
5249
|
+
visitUrlLabel: "Visitar URL:",
|
|
5250
|
+
editButtonText: "Editar",
|
|
5251
|
+
removeButtonText: "Remover",
|
|
5252
|
+
closeButtonText: "Fechar"
|
|
5253
|
+
}
|
|
5254
|
+
};
|
|
5255
|
+
const getTextEditorTranslations = (locale) => {
|
|
5256
|
+
return TEXT_EDITOR_TRANSLATIONS[locale] || TEXT_EDITOR_TRANSLATIONS["en-GB"];
|
|
5154
5257
|
};
|
|
5155
5258
|
|
|
5156
|
-
var css_248z$1 = "/**\n * --- DEPRECATED ---\n * DON'T USE ANYTHING FROM THIS FILE IN FUTURE CHANGES. WE SHOULD BE\n * USING TAILWIND CLASSES DIRECTLY IN OUR COMPONENTS.\n */\n.
|
|
5259
|
+
var css_248z$1 = "/**\n * --- DEPRECATED ---\n * DON'T USE ANYTHING FROM THIS FILE IN FUTURE CHANGES. WE SHOULD BE\n * USING TAILWIND CLASSES DIRECTLY IN OUR COMPONENTS.\n */\n.web-ui-text-editor {\n resize: vertical;\n min-height: 10rem;\n padding: 1rem;\n font-size: 0.8rem;\n line-height: 1.5;\n outline: none;\n}\n.web-ui-text-editor.tiptap.ProseMirror p.is-editor-empty:first-child::before {\n color: var(--ui-color-text-neutral-primary-disabled);\n content: attr(data-placeholder);\n float: left;\n height: 0;\n pointer-events: none;\n}\n.web-ui-text-editor a {\n color: var(--ui-color-text-brand-primary-default);\n text-decoration: underline;\n cursor: pointer;\n}\n.web-ui-text-editor ul,\n.web-ui-text-editor ol {\n padding-left: 1.5rem;\n}\n.web-ui-text-editor ul {\n list-style-type: disc;\n}\n.web-ui-text-editor ol {\n list-style-type: decimal;\n}\n.web-ui-text-editor li {\n margin-bottom: 0.25rem;\n}\n.web-ui-text-editor strong {\n font-weight: 600;\n}\n.web-ui-text-editor em {\n font-style: italic;\n}\n.web-ui-text-editor u {\n text-decoration: underline;\n}\n.web-ui-text-editor s {\n text-decoration: line-through;\n}\n.web-ui-text-editor h1,\n.web-ui-text-editor h2,\n.web-ui-text-editor h3,\n.web-ui-text-editor h4,\n.web-ui-text-editor h5,\n.web-ui-text-editor h6 {\n font-weight: 600;\n margin-bottom: 0.75rem;\n margin-top: 1rem;\n}\n.web-ui-text-editor h1:first-child,\n.web-ui-text-editor h2:first-child,\n.web-ui-text-editor h3:first-child,\n.web-ui-text-editor h4:first-child,\n.web-ui-text-editor h5:first-child,\n.web-ui-text-editor h6:first-child {\n margin-top: 0;\n}\n.web-ui-text-editor h1 {\n font-size: 2rem;\n}\n.web-ui-text-editor h2 {\n font-size: 1.5rem;\n}\n.web-ui-text-editor h3 {\n font-size: 1.25rem;\n}\n.web-ui-text-editor h4 {\n font-size: 1.125rem;\n}\n.web-ui-text-editor h5,\n.web-ui-text-editor h6 {\n font-size: 1rem;\n}";
|
|
5157
5260
|
styleInject(css_248z$1);
|
|
5158
5261
|
|
|
5159
5262
|
const sanitize = (html) => DOMPurify__default.default.sanitize(html, {
|
|
@@ -5161,7 +5264,7 @@ const sanitize = (html) => DOMPurify__default.default.sanitize(html, {
|
|
|
5161
5264
|
ALLOWED_ATTR: ["href", "target"]
|
|
5162
5265
|
});
|
|
5163
5266
|
const TextEditor = (_a) => {
|
|
5164
|
-
var { defaultValue, formats, toolbar = [
|
|
5267
|
+
var { defaultValue, formats = ["bold", "italic", "underline", "strike", "list", "link"], toolbar = [
|
|
5165
5268
|
["bold", "italic", "underline", "strike"],
|
|
5166
5269
|
[{ list: "ordered" }, { list: "bullet" }],
|
|
5167
5270
|
["link"]
|
|
@@ -5170,58 +5273,75 @@ const TextEditor = (_a) => {
|
|
|
5170
5273
|
const toolbarId = `toolbar-${rawId.replace(/:/g, "")}`;
|
|
5171
5274
|
const defaultValueRef = React.useRef(sanitize(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""));
|
|
5172
5275
|
const onTextChangeRef = React.useRef(onValueChange);
|
|
5173
|
-
const editorRef = React.useRef(null);
|
|
5174
|
-
const quillRef = React.useRef(null);
|
|
5175
5276
|
const [linkTooltip, setLinkTooltip] = React.useState(null);
|
|
5176
5277
|
const [hasTextSelected, setHasTextSelected] = React.useState(false);
|
|
5278
|
+
const locale = useLocaleContext();
|
|
5279
|
+
const translations = getTextEditorTranslations(locale);
|
|
5177
5280
|
React.useLayoutEffect(() => {
|
|
5178
5281
|
onTextChangeRef.current = onValueChange;
|
|
5179
5282
|
});
|
|
5180
|
-
|
|
5181
|
-
|
|
5182
|
-
|
|
5183
|
-
|
|
5184
|
-
|
|
5185
|
-
|
|
5186
|
-
|
|
5187
|
-
|
|
5188
|
-
|
|
5283
|
+
const editor = react.useEditor({
|
|
5284
|
+
extensions: [
|
|
5285
|
+
StarterKit__default.default.configure({
|
|
5286
|
+
// Configure extensions based on formats prop
|
|
5287
|
+
blockquote: (formats === null || formats === void 0 ? void 0 : formats.includes("blockquote")) ? {} : false,
|
|
5288
|
+
bold: (formats === null || formats === void 0 ? void 0 : formats.includes("bold")) ? {} : false,
|
|
5289
|
+
bulletList: (formats === null || formats === void 0 ? void 0 : formats.includes("list")) ? {} : false,
|
|
5290
|
+
code: (formats === null || formats === void 0 ? void 0 : formats.includes("code")) ? {} : false,
|
|
5291
|
+
heading: (formats === null || formats === void 0 ? void 0 : formats.includes("header")) ? {} : false,
|
|
5292
|
+
italic: (formats === null || formats === void 0 ? void 0 : formats.includes("italic")) ? {} : false,
|
|
5293
|
+
link: (formats === null || formats === void 0 ? void 0 : formats.includes("link")) ? {
|
|
5294
|
+
openOnClick: false,
|
|
5295
|
+
defaultProtocol: "https",
|
|
5296
|
+
HTMLAttributes: {
|
|
5297
|
+
rel: "noopener noreferrer"
|
|
5298
|
+
}
|
|
5299
|
+
} : false,
|
|
5300
|
+
orderedList: (formats === null || formats === void 0 ? void 0 : formats.includes("list")) ? {} : false,
|
|
5301
|
+
strike: (formats === null || formats === void 0 ? void 0 : formats.includes("strike")) ? {} : false,
|
|
5302
|
+
underline: (formats === null || formats === void 0 ? void 0 : formats.includes("underline")) ? {
|
|
5303
|
+
HTMLAttributes: {
|
|
5304
|
+
class: ""
|
|
5305
|
+
}
|
|
5306
|
+
} : false,
|
|
5307
|
+
codeBlock: (formats === null || formats === void 0 ? void 0 : formats.includes("code")) ? {} : false
|
|
5308
|
+
})
|
|
5309
|
+
],
|
|
5310
|
+
content: defaultValueRef.current,
|
|
5311
|
+
editorProps: {
|
|
5312
|
+
attributes: {
|
|
5313
|
+
class: "web-ui-text-editor ui:overflow-auto ui:resize-y ui:min-h-40",
|
|
5314
|
+
"data-placeholder": placeholder || ""
|
|
5189
5315
|
},
|
|
5190
|
-
|
|
5191
|
-
|
|
5192
|
-
|
|
5316
|
+
transformPastedHTML: (html) => sanitize(html),
|
|
5317
|
+
handleClick: (view, pos, event) => {
|
|
5318
|
+
const { doc } = view.state;
|
|
5319
|
+
const $pos = doc.resolve(pos);
|
|
5320
|
+
const marks = $pos.marks();
|
|
5321
|
+
const linkMark = marks.find((mark) => mark.type.name === "link");
|
|
5322
|
+
if (linkMark) {
|
|
5323
|
+
event.preventDefault();
|
|
5324
|
+
const anchor = event.target.closest("a");
|
|
5325
|
+
if (anchor) {
|
|
5326
|
+
setLinkTooltip(anchor);
|
|
5327
|
+
}
|
|
5328
|
+
return true;
|
|
5329
|
+
}
|
|
5330
|
+
return false;
|
|
5331
|
+
}
|
|
5332
|
+
},
|
|
5333
|
+
onUpdate: ({ editor: ed }) => {
|
|
5193
5334
|
var _a2;
|
|
5194
|
-
|
|
5195
|
-
|
|
5196
|
-
|
|
5197
|
-
|
|
5198
|
-
|
|
5199
|
-
|
|
5200
|
-
|
|
5201
|
-
if (defaultValueRef.current) {
|
|
5202
|
-
quill.setContents(quill.clipboard.convert({
|
|
5203
|
-
html: defaultValueRef.current
|
|
5204
|
-
}));
|
|
5205
|
-
}
|
|
5206
|
-
quillRef.current = quill;
|
|
5207
|
-
const qlEditor = editor.querySelector(".ql-editor");
|
|
5208
|
-
if (qlEditor) {
|
|
5209
|
-
qlEditor.classList.add("ui:overflow-auto", "ui:resize-y", "ui:min-h-40");
|
|
5335
|
+
const html = ed.getHTML();
|
|
5336
|
+
const json = ed.getJSON();
|
|
5337
|
+
(_a2 = onTextChangeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(onTextChangeRef, sanitize(html), json, "user");
|
|
5338
|
+
},
|
|
5339
|
+
onSelectionUpdate: ({ editor: ed }) => {
|
|
5340
|
+
const { from, to } = ed.state.selection;
|
|
5341
|
+
setHasTextSelected(from !== to);
|
|
5210
5342
|
}
|
|
5211
|
-
|
|
5212
|
-
|
|
5213
|
-
if (target.tagName === "A") {
|
|
5214
|
-
e.preventDefault();
|
|
5215
|
-
const anchor = target;
|
|
5216
|
-
setLinkTooltip(anchor);
|
|
5217
|
-
}
|
|
5218
|
-
};
|
|
5219
|
-
editor.addEventListener("click", handleEditorClick);
|
|
5220
|
-
return () => {
|
|
5221
|
-
editor.removeEventListener("click", handleEditorClick);
|
|
5222
|
-
};
|
|
5223
|
-
}, []);
|
|
5224
|
-
return jsxRuntime.jsxs(Card, Object.assign({ padding: false, border: true, borderRadius: "xs", backgroundColor: "base" }, attrs, { children: [jsxRuntime.jsx(Card.TopBar, { children: jsxRuntime.jsx(Card.Actions, { className: "ui:justify-start", children: jsxRuntime.jsx(TextEditorToolbar, { toolbarId, toolbar, hasTextSelected }) }) }), jsxRuntime.jsx(Divider, { version: "v2" }), jsxRuntime.jsx("div", { className: "editor", ref: editorRef }), jsxRuntime.jsx("div", { children: linkTooltip && quillRef.current && jsxRuntime.jsx(LinkTooltip, { linkElement: linkTooltip, quillInstance: quillRef.current, onClose: () => setLinkTooltip(null) }) })] }));
|
|
5343
|
+
});
|
|
5344
|
+
return jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs(Card, Object.assign({ padding: false, border: true, borderRadius: "xs", backgroundColor: "base" }, attrs, { children: [jsxRuntime.jsx(Card.TopBar, { children: jsxRuntime.jsx(Card.Actions, { className: "ui:justify-start", children: jsxRuntime.jsx(TextEditorToolbar, { toolbarId, toolbar, hasTextSelected, editor, translations }) }) }), jsxRuntime.jsx(Divider, { version: "v2" }), jsxRuntime.jsx(react.EditorContent, { editor }), jsxRuntime.jsx("div", {})] })), linkTooltip && editor && jsxRuntime.jsx(LinkTooltip, { linkElement: linkTooltip, editorInstance: editor, onClose: () => setLinkTooltip(null), translations })] });
|
|
5225
5345
|
};
|
|
5226
5346
|
|
|
5227
5347
|
const TextLink = (props) => {
|
|
@@ -5617,7 +5737,7 @@ const FilterMenu = (props) => {
|
|
|
5617
5737
|
const { showCheckedAmount = false, alignPopover = "left", categorizedFilter, singleSelection = false } = props;
|
|
5618
5738
|
const multiSelection = !singleSelection;
|
|
5619
5739
|
const amountOfCheckedItems = categorizedFilter.options.filter((option) => option.isChecked).length;
|
|
5620
|
-
return jsxRuntime.jsxs(react.Popover, { className: "ui:relative ui:inline-block ui:px-4 ui:text-left", children: [jsxRuntime.jsxs(react.PopoverButton, { className: "ui:group ui:inline-flex ui:justify-center ui:text-sm ui:font-medium ui:text-slate-700 ui:hover:text-slate-900", children: [jsxRuntime.jsx("span", { children: categorizedFilter.label }), amountOfCheckedItems > 0 && showCheckedAmount ? jsxRuntime.jsx("span", { className: "ui:ml-1.5 ui:rounded ui:bg-slate-200 ui:px-1.5 ui:py-0.5 ui:text-xs ui:font-semibold ui:tabular-nums ui:text-slate-700", children: amountOfCheckedItems }) : null, jsxRuntime.jsx(solid.ChevronDownIcon, { className: "ui:-mr-1 ui:ml-1 ui:h-5 ui:w-5 ui:shrink-0 ui:text-slate-400 ui:group-hover:text-slate-500", "aria-hidden": "true" })] }), jsxRuntime.jsx(react.Transition, { enter: "ui:transition ui:ease-out ui:duration-100", enterFrom: "ui:transform ui:opacity-0 ui:scale-95", enterTo: "ui:transform ui:opacity-100 ui:scale-100", leave: "ui:transition ui:ease-in ui:duration-75", leaveFrom: "ui:transform ui:opacity-100 ui:scale-100", leaveTo: "ui:transform ui:opacity-0 ui:scale-95", children: jsxRuntime.jsx(react.PopoverPanel, { className: classNames__default.default("ui:min-w-58", "ui:absolute ui:z-10 ui:mt-2", "ui:rounded-2xl ui:bg-white ui:shadow-2xl ui:ring-1 ui:ring-black ui:ring-opacity-5", "ui:focus:outline-none", "ui:border ui:border-neutral-border-high-contrast", {
|
|
5740
|
+
return jsxRuntime.jsxs(react$1.Popover, { className: "ui:relative ui:inline-block ui:px-4 ui:text-left", children: [jsxRuntime.jsxs(react$1.PopoverButton, { className: "ui:group ui:inline-flex ui:justify-center ui:text-sm ui:font-medium ui:text-slate-700 ui:hover:text-slate-900", children: [jsxRuntime.jsx("span", { children: categorizedFilter.label }), amountOfCheckedItems > 0 && showCheckedAmount ? jsxRuntime.jsx("span", { className: "ui:ml-1.5 ui:rounded ui:bg-slate-200 ui:px-1.5 ui:py-0.5 ui:text-xs ui:font-semibold ui:tabular-nums ui:text-slate-700", children: amountOfCheckedItems }) : null, jsxRuntime.jsx(solid.ChevronDownIcon, { className: "ui:-mr-1 ui:ml-1 ui:h-5 ui:w-5 ui:shrink-0 ui:text-slate-400 ui:group-hover:text-slate-500", "aria-hidden": "true" })] }), jsxRuntime.jsx(react$1.Transition, { enter: "ui:transition ui:ease-out ui:duration-100", enterFrom: "ui:transform ui:opacity-0 ui:scale-95", enterTo: "ui:transform ui:opacity-100 ui:scale-100", leave: "ui:transition ui:ease-in ui:duration-75", leaveFrom: "ui:transform ui:opacity-100 ui:scale-100", leaveTo: "ui:transform ui:opacity-0 ui:scale-95", children: jsxRuntime.jsx(react$1.PopoverPanel, { className: classNames__default.default("ui:min-w-58", "ui:absolute ui:z-10 ui:mt-2", "ui:rounded-2xl ui:bg-white ui:shadow-2xl ui:ring-1 ui:ring-black ui:ring-opacity-5", "ui:focus:outline-none", "ui:border ui:border-neutral-border-high-contrast", {
|
|
5621
5741
|
// Align popover to the left side of the button label
|
|
5622
5742
|
"ui:left-4 ui:origin-top-left": alignPopover === "left",
|
|
5623
5743
|
// Align popover to the right side of the chevron icon
|
|
@@ -5666,7 +5786,7 @@ const SortMenu = (props) => {
|
|
|
5666
5786
|
|
|
5667
5787
|
const FiltersMenus = (props) => {
|
|
5668
5788
|
const { filters, singleSelection } = props;
|
|
5669
|
-
return jsxRuntime.jsx("div", { className: "ui:hidden ui:sm:block", children: jsxRuntime.jsx("div", { className: "ui:flow-root", children: jsxRuntime.jsx(react.PopoverGroup, { className: "ui:-mx-4 ui:flex ui:items-center ui:divide-x ui:divide-slate-200", children: filters.map((categorizedFilter) => jsxRuntime.jsx(FilterMenu, { alignPopover: "right", showCheckedAmount: true, categorizedFilter, onFilterOptionChange: props.onFilterOptionChange, singleSelection }, `filter-menu-${categorizedFilter.key}`)) }) }) });
|
|
5789
|
+
return jsxRuntime.jsx("div", { className: "ui:hidden ui:sm:block", children: jsxRuntime.jsx("div", { className: "ui:flow-root", children: jsxRuntime.jsx(react$1.PopoverGroup, { className: "ui:-mx-4 ui:flex ui:items-center ui:divide-x ui:divide-slate-200", children: filters.map((categorizedFilter) => jsxRuntime.jsx(FilterMenu, { alignPopover: "right", showCheckedAmount: true, categorizedFilter, onFilterOptionChange: props.onFilterOptionChange, singleSelection }, `filter-menu-${categorizedFilter.key}`)) }) }) });
|
|
5670
5790
|
};
|
|
5671
5791
|
|
|
5672
5792
|
const isPresetFilterOption = (option) => {
|