@luscii-healthtech/web-ui 37.6.7 → 38.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.
@@ -1,5 +1,6 @@
1
1
  import React from "react";
2
2
  import type { Delta, EmitterSource } from "quill/core";
3
+ import "quill-paste-smart";
3
4
  import "quill/dist/quill.snow.css";
4
5
  import "./TextEditor.scss";
5
6
  type Props = React.HTMLAttributes<HTMLDivElement> & {
@@ -57,10 +58,6 @@ type Props = React.HTMLAttributes<HTMLDivElement> & {
57
58
  * Placeholder text to show in the editor when it is empty.
58
59
  */
59
60
  placeholder?: string;
60
- /**
61
- * Allow inline styles in the editor when pasting from clipboard.
62
- */
63
- allowInlineStyle?: boolean;
64
61
  };
65
62
  type TextEditorToolbarOption = "bold" | "italic" | "underline" | "strike" | "link" | "video" | {
66
63
  list: "ordered";
@@ -3,6 +3,7 @@
3
3
  var React = require('react');
4
4
  var classNames = require('classnames');
5
5
  var sonner = require('sonner');
6
+ var DOMPurify = require('dompurify');
6
7
  var isString = require('lodash/isString');
7
8
  var lodash = require('lodash');
8
9
  var core = require('@dnd-kit/core');
@@ -28,7 +29,7 @@ var ReactSelect = require('react-select');
28
29
  var groupBy = require('lodash/groupBy');
29
30
  var RadixSwitch = require('@radix-ui/react-switch');
30
31
  var Quill = require('quill');
31
- var DOMPurify = require('dompurify');
32
+ require('quill-paste-smart');
32
33
  require('quill/dist/quill.snow.css');
33
34
  var react = require('@headlessui/react');
34
35
  var solid = require('@heroicons/react/20/solid');
@@ -56,6 +57,7 @@ function _interopNamespace(e) {
56
57
 
57
58
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
58
59
  var classNames__default = /*#__PURE__*/_interopDefault(classNames);
60
+ var DOMPurify__default = /*#__PURE__*/_interopDefault(DOMPurify);
59
61
  var isString__default = /*#__PURE__*/_interopDefault(isString);
60
62
  var omit__default = /*#__PURE__*/_interopDefault(omit);
61
63
  var Tooltip__namespace = /*#__PURE__*/_interopNamespace(Tooltip);
@@ -69,7 +71,6 @@ var ReactSelect__default = /*#__PURE__*/_interopDefault(ReactSelect);
69
71
  var groupBy__default = /*#__PURE__*/_interopDefault(groupBy);
70
72
  var RadixSwitch__namespace = /*#__PURE__*/_interopNamespace(RadixSwitch);
71
73
  var Quill__default = /*#__PURE__*/_interopDefault(Quill);
72
- var DOMPurify__default = /*#__PURE__*/_interopDefault(DOMPurify);
73
74
  var ToggleGroup__namespace = /*#__PURE__*/_interopNamespace(ToggleGroup);
74
75
 
75
76
  /******************************************************************************
@@ -1428,7 +1429,7 @@ const allowedGroupHoverColors = {
1428
1429
  white: "group-hover:ui-text-white"
1429
1430
  };
1430
1431
  const Text = (props) => {
1431
- var _a;
1432
+ var _a, _b, _c;
1432
1433
  const { children, text, type, variant = "base", inline, color = "base", hoverColor, hoverInGroup, className, containsDangerousHtml, truncate, clampLines } = props, rest = __rest(props, ["children", "text", "type", "variant", "inline", "color", "hoverColor", "hoverInGroup", "className", "containsDangerousHtml", "truncate", "clampLines"]);
1433
1434
  const Component = inline ? "span" : "p";
1434
1435
  const resolvedVariant = type !== null && type !== void 0 ? type : variant;
@@ -1455,7 +1456,9 @@ const Text = (props) => {
1455
1456
  className
1456
1457
  )
1457
1458
  };
1458
- return containsDangerousHtml ? React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps, { dangerouslySetInnerHTML: { __html: (_a = children !== null && children !== void 0 ? children : text) !== null && _a !== void 0 ? _a : "" } })) : React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps), children !== null && children !== void 0 ? children : text);
1459
+ return containsDangerousHtml ? React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps, { dangerouslySetInnerHTML: {
1460
+ __html: (_c = (_b = DOMPurify__default.default.sanitize((_a = children === null || children === void 0 ? void 0 : children.toString()) !== null && _a !== void 0 ? _a : "")) !== null && _b !== void 0 ? _b : DOMPurify__default.default.sanitize(text !== null && text !== void 0 ? text : "")) !== null && _c !== void 0 ? _c : ""
1461
+ } })) : React__namespace.default.createElement(Component, Object.assign({}, rest, containerProps), children !== null && children !== void 0 ? children : text);
1459
1462
  };
1460
1463
 
1461
1464
  const TOASTER_TYPE_OPTIONS = {
@@ -6111,7 +6114,7 @@ const TextEditor = (_a) => {
6111
6114
  ["bold", "italic", "underline", "strike"],
6112
6115
  [{ list: "ordered" }, { list: "bullet" }],
6113
6116
  ["link"]
6114
- ], placeholder, onValueChange, allowInlineStyle = false } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "onValueChange", "allowInlineStyle"]);
6117
+ ], placeholder, onValueChange } = _a, attrs = __rest(_a, ["defaultValue", "formats", "toolbar", "placeholder", "onValueChange"]);
6115
6118
  const defaultValueRef = React.useRef(defaultValue);
6116
6119
  const onTextChangeRef = React.useRef(onValueChange);
6117
6120
  const editorRef = React.useRef(null);
@@ -6131,25 +6134,8 @@ const TextEditor = (_a) => {
6131
6134
  });
6132
6135
  quill.on(Quill__default.default.events.TEXT_CHANGE, (value, _, source) => {
6133
6136
  var _a2;
6134
- (_a2 = onTextChangeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(onTextChangeRef, !allowInlineStyle ? DOMPurify__default.default.sanitize(quill.getSemanticHTML(), {
6135
- FORBID_ATTR: ["style"]
6136
- }) : quill.getSemanticHTML(), value, source);
6137
+ (_a2 = onTextChangeRef.current) === null || _a2 === void 0 ? void 0 : _a2.call(onTextChangeRef, quill.getSemanticHTML(), value, source);
6137
6138
  });
6138
- if (!allowInlineStyle) {
6139
- quill.clipboard.addMatcher(Node.ELEMENT_NODE, (_, delta) => {
6140
- const ops = [];
6141
- const newDelta = delta;
6142
- newDelta.ops.forEach((op) => {
6143
- if (op === null || op === void 0 ? void 0 : op.attributes) {
6144
- delete op.attributes.color;
6145
- delete op.attributes.background;
6146
- ops.push(op);
6147
- }
6148
- });
6149
- newDelta.ops = ops;
6150
- return newDelta;
6151
- });
6152
- }
6153
6139
  if (defaultValueRef.current) {
6154
6140
  quill.setContents(quill.clipboard.convert({
6155
6141
  html: defaultValueRef.current