@bbl-digital/snorre 4.2.1 → 4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/bundle.js +27 -12
- package/esm/core/Html/index.js +23 -7
- package/lib/core/Html/index.d.ts +9 -1
- package/lib/core/Html/index.d.ts.map +1 -1
- package/lib/core/Html/index.js +23 -7
- package/package.json +1 -1
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')
|
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'
|
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
|
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
|
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,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9wYWNrYWdlcy9jb3JlL0FwcExvYWRlci9zdHlsZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6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dHlwZSgzKSB7XG4gICAgICAgIGxlZnQ6IDI0cHg7XG4gICAgICAgIGFuaW1hdGlvbjogbGRzLWVsbGlwc2lzMiAwLjZzIGluZmluaXRlO1xuICAgICAgfVxuICAgICAgZGl2Om50aC1vZi10eXBlKDQpIHtcbiAgICAgICAgbGVmdDogNDJweDtcbiAgICAgICAgYW5pbWF0aW9uOiBsZHMtZWxsaXBzaXMzIDAuNnMgaW5maW5pdGU7XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczEge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiBzY2FsZSgwKTtcbiAgICAgICAgfVxuICAgICAgICAxMDAlIHtcbiAgICAgICAgICB0cmFuc2Zvcm06IHNjYWxlKDEpO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczMge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiBzY2FsZSgxKTtcbiAgICAgICAgfVxuICAgICAgICAxMDAlIHtcbiAgICAgICAgICB0cmFuc2Zvcm06IHNjYWxlKDApO1xuICAgICAgICB9XG4gICAgICB9XG4gICAgICBAa2V5ZnJhbWVzIGxkcy1lbGxpcHNpczIge1xuICAgICAgICAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiB0cmFuc2xhdGUoMCwgMCk7XG4gICAgICAgIH1cbiAgICAgICAgMTAwJSB7XG4gICAgICAgICAgdHJhbnNmb3JtOiB0cmFuc2xhdGUoMThweCwgMCk7XG4gICAgICAgIH1cbiAgICAgIH1cbiAgICBgLFxufVxuXG5leHBvcnQgZGVmYXVsdCBzdHlsZXNcblxuZXhwb3J0IHsgc3R5bGVzIH1cbiJdfQ== */")
|
@@ -25028,15 +25028,30 @@
|
|
25028
25028
|
secondary,
|
25029
25029
|
size,
|
25030
25030
|
text,
|
25031
|
+
sanitize = true,
|
25032
|
+
sanitizeOptions = {},
|
25031
25033
|
whiteSpace,
|
25032
25034
|
defaultListStyles
|
25033
|
-
}) =>
|
25034
|
-
|
25035
|
-
|
25036
|
-
|
25037
|
-
|
25038
|
-
|
25039
|
-
|
25035
|
+
}) => {
|
25036
|
+
const allowedTags = sanitizeOptions?.allowedTags || [];
|
25037
|
+
const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
|
25038
|
+
const forbiddenTags = sanitizeOptions?.forbiddenTags || [];
|
25039
|
+
const forbiddenAttributes = sanitizeOptions?.forbiddenAttributes || [];
|
25040
|
+
const sanitizeOpts = {
|
25041
|
+
ALLOWED_TAGS: allowedTags,
|
25042
|
+
ALLOWED_ATTR: allowdAttributes,
|
25043
|
+
FORBID_TAGS: forbiddenTags,
|
25044
|
+
FORBID_ATTR: forbiddenAttributes
|
25045
|
+
};
|
25046
|
+
const safeHtml = sanitize ? DOMPurify__default["default"].sanitize(text, sanitizeOpts) : text;
|
25047
|
+
return jsxRuntime.jsx("div", {
|
25048
|
+
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],
|
25049
|
+
className: className || '',
|
25050
|
+
dangerouslySetInnerHTML: {
|
25051
|
+
__html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
|
25052
|
+
}
|
25053
|
+
});
|
25054
|
+
};
|
25040
25055
|
|
25041
25056
|
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
25057
|
const Wrapper$z = /*#__PURE__*/_styled__default["default"]("div", process.env.NODE_ENV === "production" ? {
|
package/esm/core/Html/index.js
CHANGED
@@ -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,28 @@ const Html = ({
|
|
10
11
|
secondary,
|
11
12
|
size,
|
12
13
|
text,
|
14
|
+
sanitize = true,
|
15
|
+
sanitizeOptions = {},
|
13
16
|
whiteSpace,
|
14
17
|
defaultListStyles
|
15
|
-
}) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
}) => {
|
19
|
+
const allowedTags = sanitizeOptions?.allowedTags || [];
|
20
|
+
const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
|
21
|
+
const forbiddenTags = sanitizeOptions?.forbiddenTags || [];
|
22
|
+
const forbiddenAttributes = sanitizeOptions?.forbiddenAttributes || [];
|
23
|
+
const sanitizeOpts = {
|
24
|
+
ALLOWED_TAGS: allowedTags,
|
25
|
+
ALLOWED_ATTR: allowdAttributes,
|
26
|
+
FORBID_TAGS: forbiddenTags,
|
27
|
+
FORBID_ATTR: forbiddenAttributes
|
28
|
+
};
|
29
|
+
const safeHtml = sanitize ? DOMPurify.sanitize(text, sanitizeOpts) : text;
|
30
|
+
return _jsx("div", {
|
31
|
+
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],
|
32
|
+
className: className || '',
|
33
|
+
dangerouslySetInnerHTML: {
|
34
|
+
__html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
|
35
|
+
}
|
36
|
+
});
|
37
|
+
};
|
22
38
|
export default Html;
|
package/lib/core/Html/index.d.ts
CHANGED
@@ -18,7 +18,15 @@ 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
|
+
forbiddenTags?: string[];
|
27
|
+
forbiddenAttributes?: string[];
|
28
|
+
};
|
21
29
|
}
|
22
|
-
declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, whiteSpace, defaultListStyles, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
30
|
+
declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, sanitize, sanitizeOptions, whiteSpace, defaultListStyles, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
|
23
31
|
export default Html;
|
24
32
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/index.tsx"],"names":[],"mappings":"
|
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;QAC5B,aAAa,CAAC,EAAE,MAAM,EAAE,CAAA;QACxB,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAA;KAC/B,CAAA;CACF;AAED,QAAA,MAAM,IAAI,wIAYP,MAAM,qDAgCR,CAAA;AAED,eAAe,IAAI,CAAA"}
|
package/lib/core/Html/index.js
CHANGED
@@ -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,28 @@ const Html = ({
|
|
10
11
|
secondary,
|
11
12
|
size,
|
12
13
|
text,
|
14
|
+
sanitize = true,
|
15
|
+
sanitizeOptions = {},
|
13
16
|
whiteSpace,
|
14
17
|
defaultListStyles
|
15
|
-
}) =>
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
}) => {
|
19
|
+
const allowedTags = sanitizeOptions?.allowedTags || [];
|
20
|
+
const allowdAttributes = sanitizeOptions?.allowedAttributes || [];
|
21
|
+
const forbiddenTags = sanitizeOptions?.forbiddenTags || [];
|
22
|
+
const forbiddenAttributes = sanitizeOptions?.forbiddenAttributes || [];
|
23
|
+
const sanitizeOpts = {
|
24
|
+
ALLOWED_TAGS: allowedTags,
|
25
|
+
ALLOWED_ATTR: allowdAttributes,
|
26
|
+
FORBID_TAGS: forbiddenTags,
|
27
|
+
FORBID_ATTR: forbiddenAttributes
|
28
|
+
};
|
29
|
+
const safeHtml = sanitize ? DOMPurify.sanitize(text, sanitizeOpts) : text;
|
30
|
+
return _jsx("div", {
|
31
|
+
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],
|
32
|
+
className: className || '',
|
33
|
+
dangerouslySetInnerHTML: {
|
34
|
+
__html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
|
35
|
+
}
|
36
|
+
});
|
37
|
+
};
|
22
38
|
export default Html;
|