@bigbinary/neeto-editor 1.43.7 → 1.43.8

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.
@@ -8,7 +8,7 @@ import CopyToClipboardButton from '@bigbinary/neeto-molecules/CopyToClipboardBut
8
8
  import { isNil } from 'ramda';
9
9
  import { createRoot } from 'react-dom/client';
10
10
  import { n } from './chunk-15c449f1.js';
11
- import { s as substituteVariables, h as highlightCode, E as EDITOR_CONTENT_CLASSNAME, S as SANITIZE_OPTIONS } from './chunk-e712f06d.js';
11
+ import { s as substituteVariables, h as highlightCode, a as applyLineHighlighting, E as EDITOR_CONTENT_CLASSNAME, S as SANITIZE_OPTIONS } from './chunk-98e9b1c3.js';
12
12
  import { useOnClickOutside } from '@bigbinary/neeto-commons-frontend/react-utils';
13
13
  import Close from '@bigbinary/neeto-icons/Close';
14
14
  import Button from '@bigbinary/neetoui/Button';
@@ -22,7 +22,7 @@ import '@bigbinary/neeto-cist';
22
22
  import 'react-dom/server';
23
23
  import '@babel/runtime/helpers/toConsumableArray';
24
24
 
25
- var css = "@charset \"UTF-8\";@import url(\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/github.min.css\");.neeto-editor-content{-moz-tab-size:2;-o-tab-size:2;tab-size:2;white-space:pre-wrap;word-break:break-word}.neeto-editor-content h1,.neeto-editor-content h2,.neeto-editor-content h3,.neeto-editor-content h4,.neeto-editor-content h5,.neeto-editor-content h6{color:rgb(var(--neeto-ui-black));font-weight:var(--neeto-ui-font-semibold)}.neeto-editor-content h1 strong,.neeto-editor-content h2 strong,.neeto-editor-content h3 strong,.neeto-editor-content h4 strong,.neeto-editor-content h5 strong,.neeto-editor-content h6 strong{font-weight:var(--neeto-ui-font-semibold)!important}.neeto-editor-content h1{font-size:var(--neeto-ui-text-h1);margin:2rem 0 .25rem}.neeto-editor-content h2{font-size:var(--neeto-ui-text-h2);margin:1.5rem 0 .25rem}.neeto-editor-content h3{font-size:var(--neeto-ui-text-h3);margin:1rem 0 .25rem}.neeto-editor-content h4{font-size:var(--neeto-ui-text-h4);margin:.75rem 0 .25rem}.neeto-editor-content h5{font-size:var(--neeto-ui-text-h5);margin:.75rem 0 .25rem}.neeto-editor-content h6{font-size:var(--neeto-ui-text-h6);margin:.75rem 0 .25rem}@media only screen and (max-width:720px){.neeto-editor-content h1{font-size:22px}.neeto-editor-content h2{font-size:20px}.neeto-editor-content h3{font-size:18px}.neeto-editor-content h4{font-size:16px}.neeto-editor-content h5{font-size:14px}.neeto-editor-content h6{font-size:12px}}.neeto-editor-content p{color:rgb(var(--neeto-ui-black));font-size:var(--neeto-ui-text-body1);font-weight:var(--neeto-ui-font-normal);line-height:var(--neeto-ui-leading-normal)}.neeto-editor-content p:empty:after{content:\" \"}.neeto-editor-content p:last-child{margin-bottom:0}.neeto-editor-content p strong{font-weight:var(--neeto-ui-font-semibold)!important}.neeto-editor-content div{color:rgb(var(--neeto-ui-black));font-size:var(--neeto-ui-text-body1);font-weight:var(--neeto-ui-font-normal);line-height:var(--neeto-ui-leading-normal)}.neeto-editor-content code{background-color:rgb(var(--neeto-ui-gray-100));border-radius:var(--neeto-ui-rounded-sm);font-family:SFMono-Regular,Menlo,Consolas,PT Mono,Liberation Mono,Courier,monospace;font-size:14px;padding:.2em .4em}.neeto-editor-content h1 code,.neeto-editor-content h2 code,.neeto-editor-content h3 code,.neeto-editor-content h4 code,.neeto-editor-content h5 code,.neeto-editor-content h6 code,.neeto-editor-content p code{font-size:inherit}.neeto-editor-content pre{background-color:#f7f6f3;border-radius:var(--neeto-ui-rounded-sm);font-size:14px;line-height:1.5;margin-bottom:16px;margin-top:16px;overflow-x:auto;padding:32px 12px 12px;position:relative}.neeto-editor-content pre .neeto-editor-codeblock-options{align-items:center;display:flex;gap:4px;position:absolute;right:4px;top:4px}.neeto-editor-content pre .neeto-editor-codeblock-options__menu{display:flex;flex-direction:column;gap:4px}.neeto-editor-content pre .neeto-editor-codeblock-options__input{margin:4px}.neeto-editor-content pre>code{background-color:transparent;border-radius:0;border-width:0;color:inherit;font-family:inherit;font-size:inherit;font-weight:400;line-height:inherit;padding:0;white-space:pre-wrap}.neeto-editor-content blockquote{border-left-color:#e5e7eb;border-left-width:4px;color:rgb(var(--neeto-ui-black));font-weight:var(--neeto-ui-font-medium);margin:8px 0;padding-left:12px;quotes:\"“\" \"”\" \"‘\" \"’\"}.neeto-editor-content blockquote>p:after,.neeto-editor-content blockquote>p:before{content:\"\"!important}.neeto-editor-content ol,.neeto-editor-content ul{list-style:revert;margin-bottom:1em;padding-left:28px}.neeto-editor-content ol li:before,.neeto-editor-content ul li:before{background-color:rgb(var(--neeto-ui-black))}.neeto-editor-content a[href]{color:rgb(var(--neeto-ui-accent-800));font-weight:500}.neeto-editor-content .neeto-editor__video-wrapper{display:flex;margin:16px 0}.neeto-editor-content .neeto-editor__video-wrapper .neeto-editor__video-iframe{border:2px solid rgb(var(--neeto-ui-gray-300));border-radius:var(--neeto-ui-rounded-lg);display:inline-block;padding:4px}.neeto-editor-content .neeto-editor__video-wrapper .neeto-editor__video-iframe iframe{height:100%;width:100%}.neeto-editor-content .neeto-editor__video--left{justify-content:flex-start}.neeto-editor-content .neeto-editor__video--right{justify-content:flex-end}.neeto-editor-content .neeto-editor__video--center{justify-content:center}.neeto-editor-content mark{border-radius:var(--neeto-ui-rounded-sm);padding:0}.neeto-editor-content [data-type=mention],.neeto-editor-content [data-type=special-mention]{color:rgb(var(--neeto-ui-accent-800))}.neeto-editor-content table{border:1px solid rgba(var(--neeto-ui-gray-300));border-collapse:separate;border-radius:var(--neeto-ui-rounded-sm);border-spacing:0;min-width:300px;overflow:hidden;table-layout:fixed}.neeto-editor-content table td,.neeto-editor-content table th{border-left:1px solid rgba(var(--neeto-ui-gray-300));border-top:1px solid rgba(var(--neeto-ui-gray-300));padding:8px 12px;position:relative}.neeto-editor-content table td:first-child,.neeto-editor-content table th:first-child{border-left:none}.neeto-editor-content table th{background:rgb(var(--neeto-ui-gray-100));border-top:none}.neeto-editor-content table td{background:rgb(var(--neeto-ui-white))}.neeto-editor-content--hidden{display:none}.neeto-editor__image-wrapper{color:inherit!important;display:flex;font-weight:400!important;margin:16px 0;padding-left:3px;text-decoration:none}.neeto-editor__image-wrapper figure{display:inline-block;max-width:100%;overflow:hidden;position:relative}.neeto-editor__image-wrapper .neeto-editor__image{border:2px solid rgb(var(--neeto-ui-gray-300));border-radius:var(--neeto-ui-rounded-lg);display:inline-block;min-height:52px;padding:4px}.neeto-editor__image-wrapper .neeto-editor__image img,.neeto-editor__image-wrapper .neeto-editor__image video{display:inline-block;height:auto;width:100%}.neeto-editor__image-wrapper .neeto-editor__image img.hidden,.neeto-editor__image-wrapper .neeto-editor__image video.hidden{display:none}.neeto-editor__image-wrapper .neeto-editor__image img{cursor:zoom-in}.neeto-editor__image-wrapper .neeto-editor__image-placeholder{align-items:center;border:1px solid;border-radius:8px;display:flex;height:200px;justify-content:center;width:400px}.neeto-editor__image-wrapper figcaption div{color:rgb(var(--neeto-ui-gray-600));font-size:14px;font-weight:var(--neeto-ui-font-normal);line-height:1.4;text-align:center}.neeto-editor__image-wrapper figcaption div a{display:inline-block;margin:0;text-align:center}.neeto-editor__image-wrapper figcaption.is-empty div:before{color:rgb(var(--neeto-ui-gray-500));content:\"Add a caption\";inset:0;position:absolute}.neeto-editor__image-wrapper:has(img:not([src])){display:none}.neeto-editor-content figcaption{color:#6b7280;font-size:14px;font-weight:400;line-height:1.4;text-align:center}.neeto-editor__image--left{justify-content:flex-start}.neeto-editor__image--center{justify-content:center}.neeto-editor__image--right{justify-content:flex-end}.selected-text{background-color:rgb(var(--neeto-ui-gray-300));padding:2px 0}.ne-image-preview-wrapper{align-items:center;background:rgba(var(--neeto-ui-gray-800),.5);display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:999999}.ne-image-preview-wrapper .ne-image-preview{background:rgb(var(--neeto-ui-white));display:flex;flex-direction:column;gap:10px;max-width:60vw;opacity:0;transition:opacity .1s ease-in-out}.ne-image-preview-wrapper .ne-image-preview.image-loaded{border-radius:10px;opacity:1;padding:10px}.ne-image-preview-wrapper .ne-image-preview__caption{color:rgb(var(--neeto-ui-gray-800));line-height:1.5}.ne-image-preview-wrapper .close-button{position:absolute;right:5px;top:5px}.ne-image-preview-wrapper .image-preview{max-height:70%;max-width:70%}.ne-image-preview-wrapper__spinner{position:absolute}.ne-image-preview-wrapper__spinner i{background-color:rgb(var(--neeto-ui-gray-300))}";
25
+ var css = "@charset \"UTF-8\";@import url(\"https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.7.2/styles/github.min.css\");.neeto-editor-content{-moz-tab-size:2;-o-tab-size:2;tab-size:2;white-space:pre-wrap;word-break:break-word}.neeto-editor-content h1,.neeto-editor-content h2,.neeto-editor-content h3,.neeto-editor-content h4,.neeto-editor-content h5,.neeto-editor-content h6{color:rgb(var(--neeto-ui-black));font-weight:var(--neeto-ui-font-semibold)}.neeto-editor-content h1 strong,.neeto-editor-content h2 strong,.neeto-editor-content h3 strong,.neeto-editor-content h4 strong,.neeto-editor-content h5 strong,.neeto-editor-content h6 strong{font-weight:var(--neeto-ui-font-semibold)!important}.neeto-editor-content h1{font-size:var(--neeto-ui-text-h1);margin:2rem 0 .25rem}.neeto-editor-content h2{font-size:var(--neeto-ui-text-h2);margin:1.5rem 0 .25rem}.neeto-editor-content h3{font-size:var(--neeto-ui-text-h3);margin:1rem 0 .25rem}.neeto-editor-content h4{font-size:var(--neeto-ui-text-h4);margin:.75rem 0 .25rem}.neeto-editor-content h5{font-size:var(--neeto-ui-text-h5);margin:.75rem 0 .25rem}.neeto-editor-content h6{font-size:var(--neeto-ui-text-h6);margin:.75rem 0 .25rem}@media only screen and (max-width:720px){.neeto-editor-content h1{font-size:22px}.neeto-editor-content h2{font-size:20px}.neeto-editor-content h3{font-size:18px}.neeto-editor-content h4{font-size:16px}.neeto-editor-content h5{font-size:14px}.neeto-editor-content h6{font-size:12px}}.neeto-editor-content p{color:rgb(var(--neeto-ui-black));font-size:var(--neeto-ui-text-body1);font-weight:var(--neeto-ui-font-normal);line-height:var(--neeto-ui-leading-normal)}.neeto-editor-content p:empty:after{content:\" \"}.neeto-editor-content p:last-child{margin-bottom:0}.neeto-editor-content p strong{font-weight:var(--neeto-ui-font-semibold)!important}.neeto-editor-content div{color:rgb(var(--neeto-ui-black));font-size:var(--neeto-ui-text-body1);font-weight:var(--neeto-ui-font-normal);line-height:var(--neeto-ui-leading-normal)}.neeto-editor-content code{background-color:rgb(var(--neeto-ui-gray-100));border-radius:var(--neeto-ui-rounded-sm);font-family:SFMono-Regular,Menlo,Consolas,PT Mono,Liberation Mono,Courier,monospace;font-size:14px;padding:.2em .4em}.neeto-editor-content h1 code,.neeto-editor-content h2 code,.neeto-editor-content h3 code,.neeto-editor-content h4 code,.neeto-editor-content h5 code,.neeto-editor-content h6 code,.neeto-editor-content p code{font-size:inherit}.neeto-editor-content pre{background-color:#f7f6f3;border-radius:var(--neeto-ui-rounded-sm);font-size:14px;line-height:1.5;margin-bottom:16px;margin-top:16px;overflow-x:auto;padding:32px 12px 12px;position:relative}.neeto-editor-content pre .neeto-editor-codeblock-options{align-items:center;display:flex;gap:4px;position:absolute;right:4px;top:4px}.neeto-editor-content pre .neeto-editor-codeblock-options__menu{display:flex;flex-direction:column;gap:4px}.neeto-editor-content pre .neeto-editor-codeblock-options__input{margin:4px}.neeto-editor-content pre .highlight-line{position:relative}.neeto-editor-content pre .highlight-line:before{left:-12px}.neeto-editor-content pre .highlight-line:after{right:-12px}.neeto-editor-content pre .highlight-line:after,.neeto-editor-content pre .highlight-line:before{background-color:inherit;content:\"\";height:25px;position:absolute;top:0;width:12px}.neeto-editor-content pre>code{background-color:transparent;border-radius:0;border-width:0;color:inherit;font-family:inherit;font-size:inherit;font-weight:400;line-height:inherit;padding:0;white-space:pre-wrap}.neeto-editor-content blockquote{border-left-color:#e5e7eb;border-left-width:4px;color:rgb(var(--neeto-ui-black));font-weight:var(--neeto-ui-font-medium);margin:8px 0;padding-left:12px;quotes:\"“\" \"”\" \"‘\" \"’\"}.neeto-editor-content blockquote>p:after,.neeto-editor-content blockquote>p:before{content:\"\"!important}.neeto-editor-content ol,.neeto-editor-content ul{list-style:revert;margin-bottom:1em;padding-left:28px}.neeto-editor-content ol li:before,.neeto-editor-content ul li:before{background-color:rgb(var(--neeto-ui-black))}.neeto-editor-content a[href]{color:rgb(var(--neeto-ui-accent-800));font-weight:500}.neeto-editor-content .neeto-editor__video-wrapper{display:flex;margin:16px 0}.neeto-editor-content .neeto-editor__video-wrapper .neeto-editor__video-iframe{border:2px solid rgb(var(--neeto-ui-gray-300));border-radius:var(--neeto-ui-rounded-lg);display:inline-block;padding:4px}.neeto-editor-content .neeto-editor__video-wrapper .neeto-editor__video-iframe iframe{height:100%;width:100%}.neeto-editor-content .neeto-editor__video--left{justify-content:flex-start}.neeto-editor-content .neeto-editor__video--right{justify-content:flex-end}.neeto-editor-content .neeto-editor__video--center{justify-content:center}.neeto-editor-content mark{border-radius:var(--neeto-ui-rounded-sm);padding:0}.neeto-editor-content [data-type=mention],.neeto-editor-content [data-type=special-mention]{color:rgb(var(--neeto-ui-accent-800))}.neeto-editor-content table{border:1px solid rgba(var(--neeto-ui-gray-300));border-collapse:separate;border-radius:var(--neeto-ui-rounded-sm);border-spacing:0;min-width:300px;overflow:hidden;table-layout:fixed}.neeto-editor-content table td,.neeto-editor-content table th{border-left:1px solid rgba(var(--neeto-ui-gray-300));border-top:1px solid rgba(var(--neeto-ui-gray-300));padding:8px 12px;position:relative}.neeto-editor-content table td:first-child,.neeto-editor-content table th:first-child{border-left:none}.neeto-editor-content table th{background:rgb(var(--neeto-ui-gray-100));border-top:none}.neeto-editor-content table td{background:rgb(var(--neeto-ui-white))}.neeto-editor-content--hidden{display:none}.neeto-editor__image-wrapper{color:inherit!important;display:flex;font-weight:400!important;margin:16px 0;padding-left:3px;text-decoration:none}.neeto-editor__image-wrapper figure{display:inline-block;max-width:100%;overflow:hidden;position:relative}.neeto-editor__image-wrapper .neeto-editor__image{border:2px solid rgb(var(--neeto-ui-gray-300));border-radius:var(--neeto-ui-rounded-lg);display:inline-block;min-height:52px;padding:4px}.neeto-editor__image-wrapper .neeto-editor__image img,.neeto-editor__image-wrapper .neeto-editor__image video{display:inline-block;height:auto;width:100%}.neeto-editor__image-wrapper .neeto-editor__image img.hidden,.neeto-editor__image-wrapper .neeto-editor__image video.hidden{display:none}.neeto-editor__image-wrapper .neeto-editor__image img{cursor:zoom-in}.neeto-editor__image-wrapper .neeto-editor__image-placeholder{align-items:center;border:1px solid;border-radius:8px;display:flex;height:200px;justify-content:center;width:400px}.neeto-editor__image-wrapper figcaption div{color:rgb(var(--neeto-ui-gray-600));font-size:14px;font-weight:var(--neeto-ui-font-normal);line-height:1.4;text-align:center}.neeto-editor__image-wrapper figcaption div a{display:inline-block;margin:0;text-align:center}.neeto-editor__image-wrapper figcaption.is-empty div:before{color:rgb(var(--neeto-ui-gray-500));content:\"Add a caption\";inset:0;position:absolute}.neeto-editor__image-wrapper:has(img:not([src])){display:none}.neeto-editor-content figcaption{color:#6b7280;font-size:14px;font-weight:400;line-height:1.4;text-align:center}.neeto-editor__image--left{justify-content:flex-start}.neeto-editor__image--center{justify-content:center}.neeto-editor__image--right{justify-content:flex-end}.selected-text{background-color:rgb(var(--neeto-ui-gray-300));padding:2px 0}.ne-image-preview-wrapper{align-items:center;background:rgba(var(--neeto-ui-gray-800),.5);display:flex;height:100%;justify-content:center;left:0;position:fixed;top:0;width:100%;z-index:999999}.ne-image-preview-wrapper .ne-image-preview{background:rgb(var(--neeto-ui-white));display:flex;flex-direction:column;gap:10px;max-width:60vw;opacity:0;transition:opacity .1s ease-in-out}.ne-image-preview-wrapper .ne-image-preview.image-loaded{border-radius:10px;opacity:1;padding:10px}.ne-image-preview-wrapper .ne-image-preview__caption{color:rgb(var(--neeto-ui-gray-800));line-height:1.5}.ne-image-preview-wrapper .close-button{position:absolute;right:5px;top:5px}.ne-image-preview-wrapper .image-preview{max-height:70%;max-width:70%}.ne-image-preview-wrapper__spinner{position:absolute}.ne-image-preview-wrapper__spinner i{background-color:rgb(var(--neeto-ui-gray-300))}";
26
26
  n(css,{});
27
27
 
28
28
  var ImagePreview = function ImagePreview(_ref) {
@@ -134,6 +134,7 @@ var EditorContent = function EditorContent(_ref) {
134
134
  useEffect(function () {
135
135
  injectCopyButtonToCodeBlocks();
136
136
  bindImageClickListener();
137
+ applyLineHighlighting(editorContentRef.current);
137
138
  }, [content]);
138
139
  return /*#__PURE__*/jsxs(Fragment, {
139
140
  children: [/*#__PURE__*/jsx("div", _objectSpread({
@@ -1 +1 @@
1
- {"version":3,"file":"EditorContent.js","sources":["../src/components/EditorContent/ImagePreview.jsx","../src/components/EditorContent/index.jsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport classnames from \"classnames\";\nimport { useOnClickOutside } from \"neetocommons/react-utils\";\nimport { Close } from \"neetoicons\";\nimport { Button, Spinner } from \"neetoui\";\nimport { createPortal } from \"react-dom\";\nimport { useTranslation } from \"react-i18next\";\n\nconst ImagePreview = ({ imagePreviewDetails, setImagePreviewDetails }) => {\n const [isLoading, setIsLoading] = useState(true);\n\n const { t } = useTranslation();\n\n const imagePreviewRef = useRef(null);\n\n useOnClickOutside(imagePreviewRef, () => setImagePreviewDetails(null), {\n enabled: true,\n });\n\n useEffect(() => {\n document.addEventListener(\n \"keydown\",\n e => e.key === \"Escape\" && setImagePreviewDetails(null)\n );\n\n return () =>\n document.removeEventListener(\n \"keydown\",\n e => e.key === \"Escape\" && setImagePreviewDetails(null)\n );\n }, []);\n\n return createPortal(\n <div className=\"ne-image-preview-wrapper\">\n {isLoading && <Spinner className=\"ne-image-preview-wrapper__spinner\" />}\n {!isLoading && (\n <div className=\"close-button\">\n <Button\n icon={Close}\n style=\"secondary\"\n onClick={() => setImagePreviewDetails(null)}\n />\n </div>\n )}\n <div\n className={classnames(\"ne-image-preview\", {\n \"image-loaded\": !isLoading,\n })}\n >\n <img\n alt={t(\"neetoEditor.editorContent.imagePreviewAltText\")}\n ref={imagePreviewRef}\n src={imagePreviewDetails.src}\n onLoad={() => setIsLoading(false)}\n />\n {imagePreviewDetails && (\n <p className=\"ne-image-preview__caption\">\n {imagePreviewDetails.caption}\n </p>\n )}\n </div>\n </div>,\n document.body\n );\n};\n\nexport default ImagePreview;\n","import { memo, useEffect, useRef, useState } from \"react\";\n\nimport classnames from \"classnames\";\nimport DOMPurify from \"dompurify\";\nimport CopyToClipboardButton from \"neetomolecules/CopyToClipboardButton\";\nimport { isNil } from \"ramda\";\nimport { createRoot } from \"react-dom/client\";\n\nimport \"src/styles/editor/editor-content.scss\";\n\nimport { EDITOR_CONTENT_CLASSNAME, SANITIZE_OPTIONS } from \"./constants\";\nimport ImagePreview from \"./ImagePreview\";\nimport { highlightCode, substituteVariables } from \"./utils\";\n\nconst EditorContent = ({\n content = \"\",\n variables = [],\n className,\n ...otherProps\n}) => {\n const [imagePreviewDetails, setImagePreviewDetails] = useState(null);\n const editorContentRef = useRef(null);\n\n const htmlContent = substituteVariables(highlightCode(content), variables);\n const sanitize = DOMPurify.sanitize;\n\n const injectCopyButtonToCodeBlocks = () => {\n const preTags = editorContentRef.current?.querySelectorAll(\n `.${EDITOR_CONTENT_CLASSNAME} pre`\n );\n\n preTags.forEach(preTag => {\n const button = document.createElement(\"div\");\n button.className = \"neeto-editor-codeblock-options\";\n const root = createRoot(button);\n root.render(\n <CopyToClipboardButton\n size=\"small\"\n style=\"text\"\n value={preTag.textContent}\n />\n );\n preTag.appendChild(button);\n });\n };\n\n const bindImageClickListener = () => {\n const figureTags = editorContentRef.current?.querySelectorAll(\n `.${EDITOR_CONTENT_CLASSNAME} figure`\n );\n\n figureTags.forEach(figureTag => {\n const image = figureTag.querySelector(\"img\");\n const link = figureTag.querySelector(\"a\");\n if (isNil(image) || isNil(link)) return;\n\n figureTag.addEventListener(\"click\", event => {\n event.preventDefault();\n const caption = figureTag.querySelector(\"figcaption\").innerText;\n setImagePreviewDetails({ src: image.src, caption });\n });\n });\n };\n\n useEffect(() => {\n injectCopyButtonToCodeBlocks();\n bindImageClickListener();\n }, [content]);\n\n return (\n <>\n <div\n data-cy=\"neeto-editor-content\"\n ref={editorContentRef}\n className={classnames(EDITOR_CONTENT_CLASSNAME, {\n [className]: className,\n })}\n dangerouslySetInnerHTML={{\n __html: sanitize(htmlContent, SANITIZE_OPTIONS),\n }}\n {...otherProps}\n />\n {imagePreviewDetails && (\n <ImagePreview {...{ imagePreviewDetails, setImagePreviewDetails }} />\n )}\n </>\n );\n};\n\nexport default memo(EditorContent);\n"],"names":["ImagePreview","_ref","imagePreviewDetails","setImagePreviewDetails","_useState","useState","_useState2","_slicedToArray","isLoading","setIsLoading","_useTranslation","useTranslation","t","imagePreviewRef","useRef","useOnClickOutside","enabled","useEffect","document","addEventListener","e","key","removeEventListener","createPortal","_jsxs","className","children","_jsx","Spinner","Button","icon","Close","style","onClick","classnames","alt","ref","src","onLoad","caption","body","EditorContent","_ref$content","content","_ref$variables","variables","otherProps","_objectWithoutProperties","_excluded","editorContentRef","htmlContent","substituteVariables","highlightCode","sanitize","DOMPurify","injectCopyButtonToCodeBlocks","_editorContentRef$cur","preTags","current","querySelectorAll","concat","EDITOR_CONTENT_CLASSNAME","forEach","preTag","button","createElement","root","createRoot","render","CopyToClipboardButton","size","value","textContent","appendChild","bindImageClickListener","_editorContentRef$cur2","figureTags","figureTag","image","querySelector","link","isNil","event","preventDefault","innerText","_Fragment","_objectSpread","_defineProperty","dangerouslySetInnerHTML","__html","SANITIZE_OPTIONS","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAAwD;AAAA,EAAA,IAAlDC,mBAAmB,GAAAD,IAAA,CAAnBC,mBAAmB;IAAEC,sBAAsB,GAAAF,IAAA,CAAtBE,sBAAsB,CAAA;AACjE,EAAA,IAAAC,SAAA,GAAkCC,QAAQ,CAAC,IA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;GACH,CAAA;AAEDtB,EAAAA,SAAS,CAAC,YAAM;AACdsC,IAAAA,4BAA4B,EAAE,CAAA;AAC9BmB,IAAAA,sBAAsB,EAAE,CAAA;AAC1B,GAAC,EAAE,CAAC/B,OAAO,CAAC,CAAC,CAAA;EAEb,oBACEnB,IAAA,CAAA6D,QAAA,EAAA;IAAA3D,QAAA,EAAA,cACEC,GAAA,CAAA,KAAA,EAAA2D,aAAA,CAAA;AACE,MAAA,SAAA,EAAQ,sBAAsB;AAC9BlD,MAAAA,GAAG,EAAEa,gBAAiB;MACtBxB,SAAS,EAAES,UAAU,CAAC2B,wBAAwB,EAAA0B,eAAA,CAAA,EAAA,EAC3C9D,SAAS,EAAGA,SAAS,CACvB,CAAE;AACH+D,MAAAA,uBAAuB,EAAE;AACvBC,QAAAA,MAAM,EAAEpC,QAAQ,CAACH,WAAW,EAAEwC,gBAAgB,CAAA;AAChD,OAAA;KACI5C,EAAAA,UAAU,CACf,CAAC,EACD5C,mBAAmB,iBAClByB,GAAA,CAAC3B,YAAY,EAAA;AAAOE,MAAAA,mBAAmB,EAAnBA,mBAAmB;AAAEC,MAAAA,sBAAsB,EAAtBA,sBAAAA;AAAsB,KAAK,CACrE,CAAA;AAAA,GACD,CAAC,CAAA;AAEP,CAAC,CAAA;AAED,YAAewF,aAAAA,IAAI,CAAClD,aAAa,CAAC;;;;"}
1
+ {"version":3,"file":"EditorContent.js","sources":["../src/components/EditorContent/ImagePreview.jsx","../src/components/EditorContent/index.jsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\n\nimport classnames from \"classnames\";\nimport { useOnClickOutside } from \"neetocommons/react-utils\";\nimport { Close } from \"neetoicons\";\nimport { Button, Spinner } from \"neetoui\";\nimport { createPortal } from \"react-dom\";\nimport { useTranslation } from \"react-i18next\";\n\nconst ImagePreview = ({ imagePreviewDetails, setImagePreviewDetails }) => {\n const [isLoading, setIsLoading] = useState(true);\n\n const { t } = useTranslation();\n\n const imagePreviewRef = useRef(null);\n\n useOnClickOutside(imagePreviewRef, () => setImagePreviewDetails(null), {\n enabled: true,\n });\n\n useEffect(() => {\n document.addEventListener(\n \"keydown\",\n e => e.key === \"Escape\" && setImagePreviewDetails(null)\n );\n\n return () =>\n document.removeEventListener(\n \"keydown\",\n e => e.key === \"Escape\" && setImagePreviewDetails(null)\n );\n }, []);\n\n return createPortal(\n <div className=\"ne-image-preview-wrapper\">\n {isLoading && <Spinner className=\"ne-image-preview-wrapper__spinner\" />}\n {!isLoading && (\n <div className=\"close-button\">\n <Button\n icon={Close}\n style=\"secondary\"\n onClick={() => setImagePreviewDetails(null)}\n />\n </div>\n )}\n <div\n className={classnames(\"ne-image-preview\", {\n \"image-loaded\": !isLoading,\n })}\n >\n <img\n alt={t(\"neetoEditor.editorContent.imagePreviewAltText\")}\n ref={imagePreviewRef}\n src={imagePreviewDetails.src}\n onLoad={() => setIsLoading(false)}\n />\n {imagePreviewDetails && (\n <p className=\"ne-image-preview__caption\">\n {imagePreviewDetails.caption}\n </p>\n )}\n </div>\n </div>,\n document.body\n );\n};\n\nexport default ImagePreview;\n","import { memo, useEffect, useRef, useState } from \"react\";\n\nimport classnames from \"classnames\";\nimport DOMPurify from \"dompurify\";\nimport CopyToClipboardButton from \"neetomolecules/CopyToClipboardButton\";\nimport { isNil } from \"ramda\";\nimport { createRoot } from \"react-dom/client\";\n\nimport \"src/styles/editor/editor-content.scss\";\n\nimport { EDITOR_CONTENT_CLASSNAME, SANITIZE_OPTIONS } from \"./constants\";\nimport ImagePreview from \"./ImagePreview\";\nimport {\n highlightCode,\n substituteVariables,\n applyLineHighlighting,\n} from \"./utils\";\n\nconst EditorContent = ({\n content = \"\",\n variables = [],\n className,\n ...otherProps\n}) => {\n const [imagePreviewDetails, setImagePreviewDetails] = useState(null);\n const editorContentRef = useRef(null);\n\n const htmlContent = substituteVariables(highlightCode(content), variables);\n const sanitize = DOMPurify.sanitize;\n\n const injectCopyButtonToCodeBlocks = () => {\n const preTags = editorContentRef.current?.querySelectorAll(\n `.${EDITOR_CONTENT_CLASSNAME} pre`\n );\n\n preTags.forEach(preTag => {\n const button = document.createElement(\"div\");\n button.className = \"neeto-editor-codeblock-options\";\n const root = createRoot(button);\n root.render(\n <CopyToClipboardButton\n size=\"small\"\n style=\"text\"\n value={preTag.textContent}\n />\n );\n preTag.appendChild(button);\n });\n };\n\n const bindImageClickListener = () => {\n const figureTags = editorContentRef.current?.querySelectorAll(\n `.${EDITOR_CONTENT_CLASSNAME} figure`\n );\n\n figureTags.forEach(figureTag => {\n const image = figureTag.querySelector(\"img\");\n const link = figureTag.querySelector(\"a\");\n if (isNil(image) || isNil(link)) return;\n\n figureTag.addEventListener(\"click\", event => {\n event.preventDefault();\n const caption = figureTag.querySelector(\"figcaption\").innerText;\n setImagePreviewDetails({ src: image.src, caption });\n });\n });\n };\n\n useEffect(() => {\n injectCopyButtonToCodeBlocks();\n bindImageClickListener();\n applyLineHighlighting(editorContentRef.current);\n }, [content]);\n\n return (\n <>\n <div\n data-cy=\"neeto-editor-content\"\n ref={editorContentRef}\n className={classnames(EDITOR_CONTENT_CLASSNAME, {\n [className]: className,\n })}\n dangerouslySetInnerHTML={{\n __html: sanitize(htmlContent, SANITIZE_OPTIONS),\n }}\n {...otherProps}\n />\n {imagePreviewDetails && (\n <ImagePreview {...{ imagePreviewDetails, setImagePreviewDetails }} />\n )}\n </>\n );\n};\n\nexport default memo(EditorContent);\n"],"names":["ImagePreview","_ref","imagePreviewDetails","setImagePreviewDetails","_useState","useState","_useState2","_slicedToArray","isLoading","setIsLoading","_useTranslation","useTranslation","t","imagePreviewRef","useRef","useOnClickOutside","enabled","useEffect","document","addEventListener","e","key","removeEventListener","createPortal","_jsxs","className","children","_jsx","Spinner","Button","icon","Close","style","onClick","classnames","alt","ref","src","onLoad","caption","body","EditorContent","_ref$content","content","_ref$variables","variables","otherProps","_objectWithoutProperties","_excluded","editorContentRef","htmlContent","substituteVariables","highlightCode","sanitize","DOMPurify","injectCopyButtonToCodeBlocks","_editorContentRef$cur","preTags","current","querySelectorAll","concat","EDITOR_CONTENT_CLASSNAME","forEach","preTag","button","createElement","root","createRoot","render","CopyToClipboardButton","size","value","textContent","appendChild","bindImageClickListener","_editorContentRef$cur2","figureTags","figureTag","image","querySelector","link","isNil","event","preventDefault","innerText","applyLineHighlighting","_Fragment","_objectSpread","_defineProperty","dangerouslySetInnerHTML","__html","SANITIZE_OPTIONS","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,IAAMA,YAAY,GAAG,SAAfA,YAAYA,CAAAC,IAAA,EAAwD;AAAA,EAAA,IAAlDC,mBAAmB,GAAAD,IAAA,CAAnBC,mBAAmB;IAAEC,sBAAsB,GAAAF,IAAA,CAAtBE,sBAAsB,CAAA;AACjE,EAAA,IAAAC,SAAA,GAAkCC,QAAQ,CAAC,IAAI,CAAC;IAAAC,UAAA,GAAAC,cAAA,CAAAH,SAAA,EAAA,CAAA,CAAA;AAAzCI,IAAAA,SAAS,GAAAF,UAAA,CAAA,CAAA,CAAA;AAAEG,IAAAA,YAAY,GAAAH,UAAA,CAAA,CAAA,CAAA,CAAA;AAE9B,EAAA,IAAAI,eAAA,GAAcC,cAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC,CAAA;AAET,EAAA,IAAMC,eAAe,GAAGC,MAAM,CAAC,IAAI,CAAC,CAAA;EAEpCC,iBAAiB,CAACF,eAAe,EAAE,YAAA;IAAA,OAAMV,sBAAsB,CAAC,IAAI,CAAC,CAAA;GAAE,EAAA;AACrEa,IAAAA,OAAO,EAAE,IAAA;AACX,GAAC,CAAC,CAAA;AAEFC,EAAAA,SAAS,CAAC,YAAM;AACdC,IAAAA,QAAQ,CAACC,gBAAgB,CACvB,SAAS,EACT,UAAAC,CAAC,EAAA;MAAA,OAAIA,CAAC,CAACC,GAAG,KAAK,QAAQ,IAAIlB,sBAAsB,CAAC,IAAI,CAAC,CAAA;AAAA,KACzD,CAAC,CAAA;IAED,OAAO,YAAA;A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MAAAA,mBAAmB,EAAnBA,mBAAmB;AAAEC,MAAAA,sBAAsB,EAAtBA,sBAAAA;AAAsB,KAAK,CACrE,CAAA;AAAA,GACD,CAAC,CAAA;AAEP,CAAC,CAAA;AAED,YAAeyF,aAAAA,IAAI,CAACnD,aAAa,CAAC;;;;"}
@@ -12516,10 +12516,13 @@ var SANITIZE_OPTIONS = {
12516
12516
  ADD_TAGS: ["iframe"],
12517
12517
  ADD_ATTR: ["target", "allow", "allowfullscreen", "frameborder"]
12518
12518
  };
12519
- var CODE_BLOCK_REGEX = /<pre><code(?:\s+class="language-([^"]*)")?>([\S\s]*?)<\/code><\/pre>/gim;
12519
+ var CODE_BLOCK_REGEX = /<pre(?:\s+[^>]+)?><code(?:\s+class="language-([^"]*)")?>([\S\s]*?)<\/code><\/pre>/gim;
12520
12520
  var VARIABLE_SPAN_REGEX = /<span data-variable="" [^>]*data-label="([^"]+)">{{([^}]+)}}<\/span>/g;
12521
12521
  var LANGUAGE_LIST = [].concat(_toConsumableArray(lowlight.listLanguages()), ["html"]);
12522
12522
 
12523
+ function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
12524
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12525
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
12523
12526
  var transformCode = function transformCode(code) {
12524
12527
  return code.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
12525
12528
  };
@@ -12530,10 +12533,58 @@ var buildReactElementFromAST = function buildReactElementFromAST(element) {
12530
12533
  }
12531
12534
  return element.value;
12532
12535
  };
12536
+ var highlightLinesCode = function highlightLinesCode(code, options) {
12537
+ code.innerHTML = code.innerHTML.replace(/([ \S]*\n|[ \S]*$)/gm, function (match) {
12538
+ return "<div class=\"highlight-line\">".concat(match, "</div>");
12539
+ });
12540
+ if (options === undefined) {
12541
+ return;
12542
+ }
12543
+ var paddingLeft = parseInt(window.getComputedStyle(code).paddingLeft);
12544
+ var paddingRight = parseInt(window.getComputedStyle(code).paddingRight);
12545
+ var lines = code.getElementsByClassName("highlight-line");
12546
+ var scroll_width = code.scrollWidth;
12547
+ // eslint-disable-next-line @bigbinary/neeto/use-array-methods
12548
+ var _iterator = _createForOfIteratorHelper(options),
12549
+ _step;
12550
+ try {
12551
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
12552
+ var option = _step.value;
12553
+ for (var j = option.start; j <= option.end; ++j) {
12554
+ lines[j].style.backgroundColor = option.color;
12555
+ lines[j].style.minWidth = "".concat(scroll_width - paddingLeft - paddingRight, "px");
12556
+ }
12557
+ }
12558
+ } catch (err) {
12559
+ _iterator.e(err);
12560
+ } finally {
12561
+ _iterator.f();
12562
+ }
12563
+ };
12564
+ var highlightLinesElement = function highlightLinesElement(code, options) {
12565
+ // eslint-disable-next-line @bigbinary/neeto/use-array-methods
12566
+ var _iterator2 = _createForOfIteratorHelper(options),
12567
+ _step2;
12568
+ try {
12569
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
12570
+ var option = _step2.value;
12571
+ --option.start;
12572
+ --option.end;
12573
+ }
12574
+ } catch (err) {
12575
+ _iterator2.e(err);
12576
+ } finally {
12577
+ _iterator2.f();
12578
+ }
12579
+ highlightLinesCode(code, options);
12580
+ };
12533
12581
  var highlightCode = function highlightCode(content) {
12534
12582
  lowlight.highlightAuto("");
12535
12583
  var highlightedAST = {};
12536
12584
  return content.replace(CODE_BLOCK_REGEX, function (_, language, code) {
12585
+ var _match$;
12586
+ var regex = /data-highlighted-lines="([^"]*)"/;
12587
+ var match = content.match(regex);
12537
12588
  if (language && LANGUAGE_LIST.includes(language)) {
12538
12589
  highlightedAST = lowlight.highlight(language, transformCode(code));
12539
12590
  } else {
@@ -12543,7 +12594,25 @@ var highlightCode = function highlightCode(content) {
12543
12594
  }
12544
12595
  }
12545
12596
  var highlightedNode = highlightedAST.children.map(buildReactElementFromAST);
12546
- return "<pre><code>".concat(renderToString(highlightedNode), "</code></pre>");
12597
+ return "<pre data-highlighted-lines=".concat((_match$ = match === null || match === void 0 ? void 0 : match[1]) !== null && _match$ !== void 0 ? _match$ : "", "><code>").concat(renderToString(highlightedNode), "</code></pre>");
12598
+ });
12599
+ };
12600
+ var applyLineHighlighting = function applyLineHighlighting(editorContent) {
12601
+ var codeTags = editorContent === null || editorContent === void 0 ? void 0 : editorContent.querySelectorAll("pre code");
12602
+ codeTags.forEach(function (codeTag) {
12603
+ var highlightedLines = codeTag.closest("pre").getAttribute("data-highlighted-lines");
12604
+ if (highlightedLines) {
12605
+ var _highlightedLines$spl;
12606
+ var linesToHighlight = (_highlightedLines$spl = highlightedLines.split(",")) === null || _highlightedLines$spl === void 0 ? void 0 : _highlightedLines$spl.map(Number);
12607
+ var highlightLinesOptions = linesToHighlight.map(function (line) {
12608
+ return {
12609
+ start: line,
12610
+ end: line,
12611
+ color: "rgba(255, 255, 0, 0.2)"
12612
+ };
12613
+ });
12614
+ highlightLinesElement(codeTag, highlightLinesOptions);
12615
+ }
12547
12616
  });
12548
12617
  };
12549
12618
  var substituteVariables = function substituteVariables(highlightedContent, variables) {
@@ -12565,5 +12634,5 @@ var substituteVariables = function substituteVariables(highlightedContent, varia
12565
12634
  });
12566
12635
  };
12567
12636
 
12568
- export { EDITOR_CONTENT_CLASSNAME as E, SANITIZE_OPTIONS as S, highlightCode as h, substituteVariables as s };
12569
- //# sourceMappingURL=chunk-e712f06d.js.map
12637
+ export { EDITOR_CONTENT_CLASSNAME as E, SANITIZE_OPTIONS as S, applyLineHighlighting as a, highlightCode as h, substituteVariables as s };
12638
+ //# sourceMappingURL=chunk-98e9b1c3.js.map