@bbl-digital/snorre 4.3.18 → 4.3.20

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.
@@ -16,6 +16,7 @@ const HtmlDefault = exports.HtmlDefault = {
16
16
  name: 'Html',
17
17
  args: {
18
18
  allowVideo: true,
19
+ disableFullscreenVideo: false,
19
20
  text: `<h1>WroomWroom</h1><h2>test</h2><h3>test</h3><h4>test</h4><p><br /></p><ol><li>test</li><li>test<ol><li>test<ol><li>test</li><li>test</li></ol></li></ol></li></ol><ul><li>test<ul><li>test<ul><li>test</li></ul></li></ul></li></ul><p><br /></p><p><img src=\"https://bbldpublicationsstgtest.blob.core.windows.net/bbldtest02/37e9fbd2-14d1-4c59-9f23-0c67d57942e9/27982f6f-542c-46cc-90c6-a365a38e6d40?sv=2024-11-04&amp;se=2040-03-21T12%3A07%3A44Z&amp;sr=b&amp;sp=r&amp;sig=1WCwtE53sk9adHcHrhVGZhuD8iU5lfKIAJzFToVBR90%3D\"></p><p>Nytt bilde</p><p><img src=\"https://bbldpublicationsstgtest.blob.core.windows.net/bbldtest02/37e9fbd2-14d1-4c59-9f23-0c67d57942e9/6768e119-627d-4981-9d70-77bea58d2794?sv=2024-11-04&amp;se=2040-03-09T08%3A07%3A03Z&amp;sr=b&amp;sp=r&amp;sig=VJSLebAwU3%2FA5aFJ3xRL6N18611SO%2BNk5YXKTOaoKkc%3D\"></p><p>tekst under bildet</p><p><br /></p><p><div>\uFEFF<span contenteditable=\"false\"><div class=\"video-container\"><br /> <iframe src=\"https://www.youtube.com/embed/hQlXebNPQAU?showinfo=0\" frameborder=\"0\" allowfullscreen=\"\"></iframe><br /> </div></span>\uFEFF</div></p>",
20
21
  st<ol><li>test</li><li>test</li><li>test</li></ol></li></ol></li></ol><br /><ul><li>test</li><li>test<ul><li>test</li></ul></li></ul>`
21
22
  }
@@ -7,7 +7,6 @@ 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");
11
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  /** @jsxImportSource @emotion/react */
@@ -23,12 +22,12 @@ const Html = ({
23
22
  sanitize = true,
24
23
  sanitizeOptions,
25
24
  whiteSpace,
26
- allowVideo = false
25
+ allowVideo = false,
26
+ disableFullscreenVideo = false
27
27
  }) => {
28
- const containerRef = (0, _react.useRef)(null);
29
28
  let _sanitizeOptions = allowVideo ? {
30
29
  ADD_TAGS: ['iframe', 'video'],
31
- ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
30
+ ADD_ATTR: disableFullscreenVideo ? ['frameborder', 'scrolling'] : ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
32
31
  ...sanitizeOptions
33
32
  } : {
34
33
  ...sanitizeOptions
@@ -36,21 +35,9 @@ const Html = ({
36
35
  let safeHtml = sanitize ? _dompurify.default.sanitize(text, _sanitizeOptions) : text;
37
36
  safeHtml = safeHtml.replace(/&nbsp;/g, ' ');
38
37
  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]);
50
38
  return (0, _jsxRuntime.jsx)("div", {
51
39
  className: classes,
52
40
  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,
54
41
  dangerouslySetInnerHTML: {
55
42
  __html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
56
43
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Html.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/Html.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,IAAI,MAAM,GAAG,CAAA;AAEpB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CAG3B,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAElC,eAAO,MAAM,WAAW,EAAE,KAQzB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAmBxB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAA"}
1
+ {"version":3,"file":"Html.stories.d.ts","sourceRoot":"","sources":["../../../src/packages/core/Html/Html.stories.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,IAAI,MAAM,GAAG,CAAA;AAEpB,QAAA,MAAM,IAAI,EAAE,IAAI,CAAC,OAAO,IAAI,CAG3B,CAAA;AAED,eAAe,IAAI,CAAA;AAEnB,KAAK,KAAK,GAAG,QAAQ,CAAC,OAAO,IAAI,CAAC,CAAA;AAElC,eAAO,MAAM,WAAW,EAAE,KASzB,CAAA;AAED,eAAO,MAAM,YAAY,EAAE,KAK1B,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAA;AAED,eAAO,MAAM,UAAU,EAAE,KAmBxB,CAAA;AAED,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAA"}
@@ -16,6 +16,7 @@ const HtmlDefault = exports.HtmlDefault = {
16
16
  name: 'Html',
17
17
  args: {
18
18
  allowVideo: true,
19
+ disableFullscreenVideo: false,
19
20
  text: `<h1>WroomWroom</h1><h2>test</h2><h3>test</h3><h4>test</h4><p><br /></p><ol><li>test</li><li>test<ol><li>test<ol><li>test</li><li>test</li></ol></li></ol></li></ol><ul><li>test<ul><li>test<ul><li>test</li></ul></li></ul></li></ul><p><br /></p><p><img src=\"https://bbldpublicationsstgtest.blob.core.windows.net/bbldtest02/37e9fbd2-14d1-4c59-9f23-0c67d57942e9/27982f6f-542c-46cc-90c6-a365a38e6d40?sv=2024-11-04&amp;se=2040-03-21T12%3A07%3A44Z&amp;sr=b&amp;sp=r&amp;sig=1WCwtE53sk9adHcHrhVGZhuD8iU5lfKIAJzFToVBR90%3D\"></p><p>Nytt bilde</p><p><img src=\"https://bbldpublicationsstgtest.blob.core.windows.net/bbldtest02/37e9fbd2-14d1-4c59-9f23-0c67d57942e9/6768e119-627d-4981-9d70-77bea58d2794?sv=2024-11-04&amp;se=2040-03-09T08%3A07%3A03Z&amp;sr=b&amp;sp=r&amp;sig=VJSLebAwU3%2FA5aFJ3xRL6N18611SO%2BNk5YXKTOaoKkc%3D\"></p><p>tekst under bildet</p><p><br /></p><p><div>\uFEFF<span contenteditable=\"false\"><div class=\"video-container\"><br /> <iframe src=\"https://www.youtube.com/embed/hQlXebNPQAU?showinfo=0\" frameborder=\"0\" allowfullscreen=\"\"></iframe><br /> </div></span>\uFEFF</div></p>",
20
21
  st<ol><li>test</li><li>test</li><li>test</li></ol></li></ol></li></ol><br /><ul><li>test</li><li>test<ul><li>test</li></ul></li></ul>`
21
22
  }
@@ -25,7 +25,9 @@ interface IProps {
25
25
  sanitizeOptions?: Config;
26
26
  /** Allow video tags */
27
27
  allowVideo?: boolean;
28
+ /** Disable fullscreen video */
29
+ disableFullscreenVideo?: boolean;
28
30
  }
29
- declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, sanitize, sanitizeOptions, whiteSpace, allowVideo, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
31
+ declare const Html: ({ className, dark, externalLinks, removeMargins, secondary, size, text, sanitize, sanitizeOptions, whiteSpace, allowVideo, disableFullscreenVideo, }: IProps) => import("@emotion/react/jsx-runtime").JSX.Element;
30
32
  export default Html;
31
33
  //# sourceMappingURL=index.d.ts.map
@@ -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;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"}
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;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;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,gCAAgC;IAChC,eAAe,CAAC,EAAE,MAAM,CAAA;IACxB,uBAAuB;IACvB,UAAU,CAAC,EAAE,OAAO,CAAA;IAEpB,+BAA+B;IAC/B,sBAAsB,CAAC,EAAE,OAAO,CAAA;CACjC;AAED,QAAA,MAAM,IAAI,GAAI,sJAaX,MAAM,qDAkCR,CAAA;AAED,eAAe,IAAI,CAAA"}
@@ -7,7 +7,6 @@ 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");
11
10
  var _jsxRuntime = require("@emotion/react/jsx-runtime");
12
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
12
  /** @jsxImportSource @emotion/react */
@@ -23,12 +22,12 @@ const Html = ({
23
22
  sanitize = true,
24
23
  sanitizeOptions,
25
24
  whiteSpace,
26
- allowVideo = false
25
+ allowVideo = false,
26
+ disableFullscreenVideo = false
27
27
  }) => {
28
- const containerRef = (0, _react.useRef)(null);
29
28
  let _sanitizeOptions = allowVideo ? {
30
29
  ADD_TAGS: ['iframe', 'video'],
31
- ADD_ATTR: ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
30
+ ADD_ATTR: disableFullscreenVideo ? ['frameborder', 'scrolling'] : ['allow', 'allowfullscreen', 'frameborder', 'scrolling'],
32
31
  ...sanitizeOptions
33
32
  } : {
34
33
  ...sanitizeOptions
@@ -36,21 +35,9 @@ const Html = ({
36
35
  let safeHtml = sanitize ? _dompurify.default.sanitize(text, _sanitizeOptions) : text;
37
36
  safeHtml = safeHtml.replace(/&nbsp;/g, ' ');
38
37
  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]);
50
38
  return (0, _jsxRuntime.jsx)("div", {
51
39
  className: classes,
52
40
  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,
54
41
  dangerouslySetInnerHTML: {
55
42
  __html: externalLinks ? safeHtml.replace(/href/g, "target='_blank' href") : safeHtml
56
43
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbl-digital/snorre",
3
- "version": "4.3.18",
3
+ "version": "4.3.20",
4
4
  "description": "Design library for BBL Digital",
5
5
  "license": "MIT",
6
6
  "main": "./lib/index.js",