@bbl-digital/snorre 4.3.17 → 4.3.18
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/esm/core/Html/index.js
CHANGED
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
7
7
|
var _styles = require("./styles");
|
8
8
|
var _dompurify = _interopRequireDefault(require("dompurify"));
|
9
9
|
require("quill/dist/quill.snow.css");
|
10
|
+
var _react = require("react");
|
10
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
13
|
/** @jsxImportSource @emotion/react */
|
@@ -24,6 +25,7 @@ const Html = ({
|
|
24
25
|
whiteSpace,
|
25
26
|
allowVideo = false
|
26
27
|
}) => {
|
28
|
+
const containerRef = (0, _react.useRef)(null);
|
27
29
|
let _sanitizeOptions = allowVideo ? {
|
28
30
|
ADD_TAGS: ['iframe', 'video'],
|
29
31
|
ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
|
@@ -34,9 +36,21 @@ const Html = ({
|
|
34
36
|
let safeHtml = sanitize ? _dompurify.default.sanitize(text, _sanitizeOptions) : text;
|
35
37
|
safeHtml = safeHtml.replace(/ /g, ' ');
|
36
38
|
const classes = `snorre-html ${className || ''}`;
|
39
|
+
(0, _react.useEffect)(() => {
|
40
|
+
if (!allowVideo) return;
|
41
|
+
if (containerRef.current) {
|
42
|
+
console.log('containerRef.current', containerRef.current);
|
43
|
+
const iframes = containerRef.current.querySelectorAll('iframe');
|
44
|
+
iframes.forEach(iframe => {
|
45
|
+
iframe.setAttribute('allow', 'autoplay; fullscreen; picture-in-picture');
|
46
|
+
iframe.setAttribute('allowfullscreen', '');
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}, [text, allowVideo]);
|
37
50
|
return (0, _jsxRuntime.jsx)("div", {
|
38
51
|
className: classes,
|
39
52
|
css: theme => [_styles.styles.default(theme), secondary && _styles.styles.secondary(theme), dark && _styles.styles.dark(theme), size && _styles.styles.size(size), _styles.styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && _styles.styles.removeMargins],
|
53
|
+
ref: containerRef,
|
40
54
|
dangerouslySetInnerHTML: {
|
41
55
|
__html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
|
42
56
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,2BAA2B,CAAA;
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/index.tsx"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAA;AACvC,OAAO,2BAA2B,CAAA;AAGlC,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;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uBAAuB;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB;AAED,QAAA,MAAM,IAAI,GAAI,8HAYX,MAAM,qDA+CR,CAAA;AAED,eAAe,IAAI,CAAA"}
|
package/lib/core/Html/index.js
CHANGED
@@ -7,6 +7,7 @@ exports.default = void 0;
|
|
7
7
|
var _styles = require("./styles");
|
8
8
|
var _dompurify = _interopRequireDefault(require("dompurify"));
|
9
9
|
require("quill/dist/quill.snow.css");
|
10
|
+
var _react = require("react");
|
10
11
|
var _jsxRuntime = require("@emotion/react/jsx-runtime");
|
11
12
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
12
13
|
/** @jsxImportSource @emotion/react */
|
@@ -24,6 +25,7 @@ const Html = ({
|
|
24
25
|
whiteSpace,
|
25
26
|
allowVideo = false
|
26
27
|
}) => {
|
28
|
+
const containerRef = (0, _react.useRef)(null);
|
27
29
|
let _sanitizeOptions = allowVideo ? {
|
28
30
|
ADD_TAGS: ['iframe', 'video'],
|
29
31
|
ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
|
@@ -34,9 +36,21 @@ const Html = ({
|
|
34
36
|
let safeHtml = sanitize ? _dompurify.default.sanitize(text, _sanitizeOptions) : text;
|
35
37
|
safeHtml = safeHtml.replace(/ /g, ' ');
|
36
38
|
const classes = `snorre-html ${className || ''}`;
|
39
|
+
(0, _react.useEffect)(() => {
|
40
|
+
if (!allowVideo) return;
|
41
|
+
if (containerRef.current) {
|
42
|
+
console.log('containerRef.current', containerRef.current);
|
43
|
+
const iframes = containerRef.current.querySelectorAll('iframe');
|
44
|
+
iframes.forEach(iframe => {
|
45
|
+
iframe.setAttribute('allow', 'autoplay; fullscreen; picture-in-picture');
|
46
|
+
iframe.setAttribute('allowfullscreen', '');
|
47
|
+
});
|
48
|
+
}
|
49
|
+
}, [text, allowVideo]);
|
37
50
|
return (0, _jsxRuntime.jsx)("div", {
|
38
51
|
className: classes,
|
39
52
|
css: theme => [_styles.styles.default(theme), secondary && _styles.styles.secondary(theme), dark && _styles.styles.dark(theme), size && _styles.styles.size(size), _styles.styles.whiteSpace(whiteSpace ? whiteSpace : 'pre-wrap'), removeMargins && _styles.styles.removeMargins],
|
53
|
+
ref: containerRef,
|
40
54
|
dangerouslySetInnerHTML: {
|
41
55
|
__html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
|
42
56
|
}
|
@@ -5,15 +5,15 @@ export declare const basicToolbar: (string[] | ({
|
|
5
5
|
indent: string;
|
6
6
|
list?: undefined;
|
7
7
|
})[])[];
|
8
|
-
export declare const richToolbar: (string[] |
|
8
|
+
export declare const richToolbar: (string[] | {
|
9
|
+
header: (number | boolean)[];
|
10
|
+
}[] | ({
|
9
11
|
list: string;
|
10
12
|
indent?: undefined;
|
11
13
|
} | {
|
12
14
|
indent: string;
|
13
15
|
list?: undefined;
|
14
16
|
})[] | {
|
15
|
-
header: (number | boolean)[];
|
16
|
-
}[] | {
|
17
17
|
align: string;
|
18
18
|
}[])[];
|
19
19
|
//# sourceMappingURL=config.d.ts.map
|