@luscii-healthtech/web-ui 48.1.2 → 48.1.4

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.
@@ -5371,6 +5371,10 @@ const TextEditorToolbar = ({ toolbarId, toolbar, hasTextSelected }) => {
5371
5371
  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.ql-editor {\n resize: vertical;\n min-height: 10rem;\n padding: 1rem;\n font-size: 0.8rem;\n line-height: 1.5;\n}\n.ql-editor a {\n color: var(--ui-color-text-brand-primary-default);\n text-decoration: underline;\n cursor: pointer;\n}\n.ql-editor ul,\n.ql-editor ol {\n padding-left: 1.5rem;\n}\n.ql-editor ul {\n list-style-type: disc;\n}\n.ql-editor ol {\n list-style-type: decimal;\n}\n.ql-editor li {\n margin-bottom: 0.25rem;\n}\n.ql-editor strong {\n font-weight: 600;\n}\n.ql-editor em {\n font-style: italic;\n}\n.ql-editor u {\n text-decoration: underline;\n}\n.ql-editor s {\n text-decoration: line-through;\n}\n.ql-editor h1,\n.ql-editor h2,\n.ql-editor h3,\n.ql-editor h4,\n.ql-editor h5,\n.ql-editor h6 {\n font-weight: 600;\n margin-bottom: 0.75rem;\n margin-top: 1rem;\n}\n.ql-editor h1:first-child,\n.ql-editor h2:first-child,\n.ql-editor h3:first-child,\n.ql-editor h4:first-child,\n.ql-editor h5:first-child,\n.ql-editor h6:first-child {\n margin-top: 0;\n}\n.ql-editor h1 {\n font-size: 2rem;\n}\n.ql-editor h2 {\n font-size: 1.5rem;\n}\n.ql-editor h3 {\n font-size: 1.25rem;\n}\n.ql-editor h4 {\n font-size: 1.125rem;\n}\n.ql-editor h5,\n.ql-editor h6 {\n font-size: 1rem;\n}";
5372
5372
  styleInject(css_248z$1);
5373
5373
 
5374
+ const sanitize = (html) => DOMPurify__default.default.sanitize(html, {
5375
+ ALLOWED_TAGS: ["u", "a", "s", "ul", "ol", "li", "p", "strong", "em"],
5376
+ ALLOWED_ATTR: ["href", "target"]
5377
+ });
5374
5378
  const TextEditor = (_a) => {
5375
5379
  var { defaultValue, formats, toolbar = [
5376
5380
  ["bold", "italic", "underline", "strike"],
@@ -5379,7 +5383,7 @@ const TextEditor = (_a) => {
5379
5383
  ], placeholder, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "onValueChange"]);
5380
5384
  const rawId = React.useId();
5381
5385
  const toolbarId = `toolbar-${rawId.replace(/:/g, "")}`;
5382
- const defaultValueRef = React.useRef(defaultValue);
5386
+ const defaultValueRef = React.useRef(sanitize(defaultValue !== null && defaultValue !== void 0 ? defaultValue : ""));
5383
5387
  const onTextChangeRef = React.useRef(onValueChange);
5384
5388
  const editorRef = React.useRef(null);
5385
5389
  const quillRef = React.useRef(null);
@@ -5402,7 +5406,7 @@ const TextEditor = (_a) => {
5402
5406
  });
5403
5407
  quill.on(Quill__default.default.events.TEXT_CHANGE, (value, _, source) => {
5404
5408
  var _a2;
5405
- (_a2 = onTextChangeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(onTextChangeRef, quill.getSemanticHTML(), value, source);
5409
+ (_a2 = onTextChangeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(onTextChangeRef, sanitize(quill.getSemanticHTML()), value, source);
5406
5410
  });
5407
5411
  const handleSelectionChange = () => {
5408
5412
  const selection = quill.getSelection();