@bbl-digital/snorre 4.2.1 → 4.2.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/bundle.js CHANGED
@@ -1,18 +1,18 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@emotion/styled/base'), require('react'), require('@emotion/react'), require('@emotion/react/jsx-runtime'), require('react/jsx-runtime'), require('react-transition-group'), require('react-player'), require('react-aria'), require('quill/dist/quill.snow.css'), require('match-sorter'), require('body-scroll-lock'), require('framer-motion'), require('recharts'), require('nuka-carousel'), require('react-day-picker'), require('date-fns/locale'), require('react-popper'), require('date-fns'), require('react-beautiful-dnd'), require('react-images-uploading'), require('react-stately'), require('quill'), require('dompurify')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@emotion/styled/base', 'react', '@emotion/react', '@emotion/react/jsx-runtime', 'react/jsx-runtime', 'react-transition-group', 'react-player', 'react-aria', 'quill/dist/quill.snow.css', 'match-sorter', 'body-scroll-lock', 'framer-motion', 'recharts', 'nuka-carousel', 'react-day-picker', 'date-fns/locale', 'react-popper', 'date-fns', 'react-beautiful-dnd', 'react-images-uploading', 'react-stately', 'quill', 'dompurify'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Snorre = {}, global._styled, global.React, global.react, global.jsxRuntime, global.jsxRuntime$1, global.reactTransitionGroup, global.ReactPlayer, global.reactAria, null, global.matchSorter, global.bodyScrollLock, global.framerMotion, global.recharts, global.Carousel, global.reactDayPicker, global.locale, global.reactPopper, global.dateFns, global.reactBeautifulDnd, global.ImageUploading, global.reactStately, global.Quill, global.DOMPurify));
5
- })(this, (function (exports, _styled, React, react, jsxRuntime, jsxRuntime$1, reactTransitionGroup, ReactPlayer, reactAria, quill_snow_css, matchSorter, bodyScrollLock, framerMotion, recharts, Carousel, reactDayPicker, locale, reactPopper, dateFns, reactBeautifulDnd, ImageUploading, reactStately, Quill, DOMPurify) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@emotion/styled/base'), require('react'), require('@emotion/react'), require('@emotion/react/jsx-runtime'), require('react/jsx-runtime'), require('react-transition-group'), require('react-player'), require('react-aria'), require('dompurify'), require('quill/dist/quill.snow.css'), require('match-sorter'), require('body-scroll-lock'), require('framer-motion'), require('recharts'), require('nuka-carousel'), require('react-day-picker'), require('date-fns/locale'), require('react-popper'), require('date-fns'), require('react-beautiful-dnd'), require('react-images-uploading'), require('react-stately'), require('quill')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@emotion/styled/base', 'react', '@emotion/react', '@emotion/react/jsx-runtime', 'react/jsx-runtime', 'react-transition-group', 'react-player', 'react-aria', 'dompurify', 'quill/dist/quill.snow.css', 'match-sorter', 'body-scroll-lock', 'framer-motion', 'recharts', 'nuka-carousel', 'react-day-picker', 'date-fns/locale', 'react-popper', 'date-fns', 'react-beautiful-dnd', 'react-images-uploading', 'react-stately', 'quill'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Snorre = {}, global._styled, global.React, global.react, global.jsxRuntime, global.jsxRuntime$1, global.reactTransitionGroup, global.ReactPlayer, global.reactAria, global.DOMPurify, null, global.matchSorter, global.bodyScrollLock, global.framerMotion, global.recharts, global.Carousel, global.reactDayPicker, global.locale, global.reactPopper, global.dateFns, global.reactBeautifulDnd, global.ImageUploading, global.reactStately, global.Quill));
5
+ })(this, (function (exports, _styled, React, react, jsxRuntime, jsxRuntime$1, reactTransitionGroup, ReactPlayer, reactAria, DOMPurify, quill_snow_css, matchSorter, bodyScrollLock, framerMotion, recharts, Carousel, reactDayPicker, locale, reactPopper, dateFns, reactBeautifulDnd, ImageUploading, reactStately, Quill) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var _styled__default = /*#__PURE__*/_interopDefaultLegacy(_styled);
10
10
  var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
11
11
  var ReactPlayer__default = /*#__PURE__*/_interopDefaultLegacy(ReactPlayer);
12
+ var DOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(DOMPurify);
12
13
  var Carousel__default = /*#__PURE__*/_interopDefaultLegacy(Carousel);
13
14
  var ImageUploading__default = /*#__PURE__*/_interopDefaultLegacy(ImageUploading);
14
15
  var Quill__default = /*#__PURE__*/_interopDefaultLegacy(Quill);
15
- var DOMPurify__default = /*#__PURE__*/_interopDefaultLegacy(DOMPurify);
16
16
 
17
17
  const styles$B = {
18
18
  default: (theme, color) => /*#__PURE__*/react.css("display:inline-block;position:relative;min-width:58px;height:10px;div{position:absolute;width:10px;height:10px;border-radius:50%;background:", color ? color : '#ccc', ";animation-timing-function:cubic-bezier(0, 1, 1, 0);}div:nth-of-type(1){left:6px;animation:lds-ellipsis1 0.6s infinite;}div:nth-of-type(2){left:6px;animation:lds-ellipsis2 0.6s infinite;}div:nth-of-type(3){left:24px;animation:lds-ellipsis2 0.6s infinite;}div:nth-of-type(4){left:42px;animation:lds-ellipsis3 0.6s infinite;}@keyframes lds-ellipsis1{0%{transform:scale(0);}100%{transform:scale(1);}}@keyframes lds-ellipsis3{0%{transform:scale(1);}100%{transform:scale(0);}}@keyframes lds-ellipsis2{0%{transform:translate(0, 0);}100%{transform:translate(18px, 0);}}" + (process.env.NODE_ENV === "production" ? "" : ";label:default;"), process.env.NODE_ENV === "production" ? "" : "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYWNrYWdlcy9jb3JlL0FwcExvYWRlci9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBS08iLCJmaWxlIjoiLi4vLi4vLi4vc3JjL3BhY2thZ2VzL2NvcmUvQXBwTG9hZGVyL3N0eWxlcy50cyIsInNvdXJjZXNDb250ZW50IjpbImltcG9ydCB7IGNzcyB9IGZyb20gJ0BlbW90aW9uL3JlYWN0J1xuaW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bGVmdDogNDJweDtcbiAgICAgICAgYW5pbWF0aW9uOiBsZHMtZWxsaXBzaXMzIDAuNnMgaW5maW5pdGU7XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczEge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiBzY2FsZSgwKTtcbiAgICAgICAgfVxuICAgICAgICAxMDAlIHtcbiAgICAgICAgICB0cmFuc2Zvcm06IHNjYWxlKDEpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczMge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiBzY2FsZSgxKTtcbiAgICAgICAgfVxuICAgICAgICAxMDAlIHtcbiAgICAgICAgICB0cmFuc2Zvcm06IHNjYWxlKDApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczIge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiB0cmFuc2xhdGUoMCwgMCk7XG4gICAgICAgIH1cbiAgICAgICAgMTAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiB0cmFuc2xhdGUoMThweCwgMCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICBgLFxufVxuXG5leHBvcnQgZGVmYXVsdCBzdHlsZXNcblxuZXhwb3J0IHsgc3R5bGVzIH1cbiJdfQ== */")
@@ -25028,15 +25028,26 @@
25028
25028
  secondary,
25029
25029
  size,
25030
25030
  text,
25031
+ sanitize,
25032
+ sanitizeOptions,
25031
25033
  whiteSpace,
25032
25034
  defaultListStyles
25033
- }) => jsxRuntime.jsx("div", {
25034
- css: theme => [styles$l.default(theme), secondary && styles$l.secondary(theme), dark && styles$l.dark(theme), size && styles$l.size(size), styles$l.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles$l.removeMargins, defaultListStyles && styles$l.defaultListStyles],
25035
- className: className || '',
25036
- dangerouslySetInnerHTML: {
25037
- __html: externalLinks ? text.replace(/href/g, "target='_blank' href") : text
25038
- }
25039
- });
25035
+ }) => {
25036
+ const allowedTags = sanitizeOptions?.allowedTags || [];
25037
+ const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
25038
+ const sanitizeOpts = {
25039
+ ALLOWED_TAGS: allowedTags,
25040
+ ALLOWED_ATTR: allowdAttributes
25041
+ };
25042
+ const safeHtml = sanitize ? DOMPurify__default["default"].sanitize(text, sanitizeOpts) : text;
25043
+ return jsxRuntime.jsx("div", {
25044
+ css: theme => [styles$l.default(theme), secondary && styles$l.secondary(theme), dark && styles$l.dark(theme), size && styles$l.size(size), styles$l.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles$l.removeMargins, defaultListStyles && styles$l.defaultListStyles],
25045
+ className: className || '',
25046
+ dangerouslySetInnerHTML: {
25047
+ __html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
25048
+ }
25049
+ });
25050
+ };
25040
25051
 
25041
25052
  function _EMOTION_STRINGIFIED_CSS_ERROR__$_() { return "You have tried to stringify object returned from `css` function. It isn't supposed to be used directly (e.g. as value of the `className` prop), but rather handed to emotion so it can handle it (e.g. as value of `css` prop)."; }
25042
25053
  const Wrapper$z = /*#__PURE__*/_styled__default["default"]("div", process.env.NODE_ENV === "production" ? {
@@ -1,5 +1,6 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { styles } from './styles';
3
+ import DOMPurify from 'dompurify';
3
4
  import 'quill/dist/quill.snow.css';
4
5
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
5
6
  const Html = ({
@@ -10,13 +11,24 @@ const Html = ({
10
11
  secondary,
11
12
  size,
12
13
  text,
14
+ sanitize,
15
+ sanitizeOptions,
13
16
  whiteSpace,
14
17
  defaultListStyles
15
- }) => _jsx("div", {
16
- css: theme => [styles.default(theme), secondary && styles.secondary(theme), dark && styles.dark(theme), size && styles.size(size), styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles.removeMargins, defaultListStyles && styles.defaultListStyles],
17
- className: className || '',
18
- dangerouslySetInnerHTML: {
19
- __html: externalLinks ? text.replace(/href/g, "target='_blank' href") : text
20
- }
21
- });
18
+ }) => {
19
+ const allowedTags = sanitizeOptions?.allowedTags || [];
20
+ const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
21
+ const sanitizeOpts = {
22
+ ALLOWED_TAGS: allowedTags,
23
+ ALLOWED_ATTR: allowdAttributes
24
+ };
25
+ const safeHtml = sanitize ? DOMPurify.sanitize(text, sanitizeOpts) : text;
26
+ return _jsx("div", {
27
+ css: theme => [styles.default(theme), secondary && styles.secondary(theme), dark && styles.dark(theme), size && styles.size(size), styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles.removeMargins, defaultListStyles && styles.defaultListStyles],
28
+ className: className || '',
29
+ dangerouslySetInnerHTML: {
30
+ __html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
31
+ }
32
+ });
33
+ };
22
34
  export default Html;
@@ -18,7 +18,13 @@ interface IProps {
18
18
  className?: string;
19
19
  /** Specifies that we want to use default list styles and not quills */
20
20
  defaultListStyles?: boolean;
21
+ /** Optionally sanitize before render. E.g. if you want to remove styles */
22
+ sanitize?: boolean;
23
+ sanitizeOptions?: {
24
+ allowedTags?: string[];
25
+ allowedAttributes?: string[];
26
+ };
21
27
  }
22
- declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, whiteSpace, defaultListStyles, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
28
+ declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, sanitize, sanitizeOptions, whiteSpace, defaultListStyles, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
23
29
  export default Html;
24
30
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/index.tsx"],"names":[],"mappings":"AAEA,OAAO,2BAA2B,CAAA;AAElC,UAAU,MAAM;IACd,4BAA4B;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED,QAAA,MAAM,IAAI,6GAUP,MAAM,qDAkBR,CAAA;AAED,eAAe,IAAI,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/index.tsx"],"names":[],"mappings":"AAGA,OAAO,2BAA2B,CAAA;AAElC,UAAU,MAAM;IACd,4BAA4B;IAC5B,IAAI,CAAC,EAAE,GAAG,CAAA;IACV,2BAA2B;IAC3B,SAAS,CAAC,EAAE,OAAO,CAAA;IACnB,gCAAgC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,4BAA4B;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,mCAAmC;IACnC,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,4DAA4D;IAC5D,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,4DAA4D;IAC5D,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,sBAAsB;IACtB,SAAS,CAAC,EAAE,MAAM,CAAA;IAClB,uEAAuE;IACvE,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,eAAe,CAAC,EAAE;QAChB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;QACtB,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;KAC7B,CAAA;CACF;AAED,QAAA,MAAM,IAAI,wIAYP,MAAM,qDA4BR,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -1,5 +1,6 @@
1
1
  /** @jsxImportSource @emotion/react */
2
2
  import { styles } from './styles';
3
+ import DOMPurify from 'dompurify';
3
4
  import 'quill/dist/quill.snow.css';
4
5
  import { jsx as _jsx } from "@emotion/react/jsx-runtime";
5
6
  const Html = ({
@@ -10,13 +11,24 @@ const Html = ({
10
11
  secondary,
11
12
  size,
12
13
  text,
14
+ sanitize,
15
+ sanitizeOptions,
13
16
  whiteSpace,
14
17
  defaultListStyles
15
- }) => _jsx("div", {
16
- css: theme => [styles.default(theme), secondary && styles.secondary(theme), dark && styles.dark(theme), size && styles.size(size), styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles.removeMargins, defaultListStyles && styles.defaultListStyles],
17
- className: className || '',
18
- dangerouslySetInnerHTML: {
19
- __html: externalLinks ? text.replace(/href/g, "target='_blank' href") : text
20
- }
21
- });
18
+ }) => {
19
+ const allowedTags = sanitizeOptions?.allowedTags || [];
20
+ const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
21
+ const sanitizeOpts = {
22
+ ALLOWED_TAGS: allowedTags,
23
+ ALLOWED_ATTR: allowdAttributes
24
+ };
25
+ const safeHtml = sanitize ? DOMPurify.sanitize(text, sanitizeOpts) : text;
26
+ return _jsx("div", {
27
+ css: theme => [styles.default(theme), secondary && styles.secondary(theme), dark && styles.dark(theme), size && styles.size(size), styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && styles.removeMargins, defaultListStyles && styles.defaultListStyles],
28
+ className: className || '',
29
+ dangerouslySetInnerHTML: {
30
+ __html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
31
+ }
32
+ });
33
+ };
22
34
  export default Html;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "4.2.1",
3
+ "version": "4.2.2",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",