@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.
- package/dist/Editor.js +157 -5
- package/dist/Editor.js.map +1 -1
- package/dist/EditorContent.js +3 -2
- package/dist/EditorContent.js.map +1 -1
- package/dist/{chunk-e712f06d.js → chunk-98e9b1c3.js} +73 -4
- package/dist/{chunk-e712f06d.js.map → chunk-98e9b1c3.js.map} +1 -1
- package/dist/cjs/Editor.cjs.js +157 -4
- package/dist/cjs/Editor.cjs.js.map +1 -1
- package/dist/cjs/EditorContent.cjs.js +3 -2
- package/dist/cjs/EditorContent.cjs.js.map +1 -1
- package/dist/cjs/{chunk-54dedc79.cjs.js → chunk-de3ec26b.cjs.js} +73 -3
- package/dist/cjs/{chunk-54dedc79.cjs.js.map → chunk-de3ec26b.cjs.js.map} +1 -1
- package/dist/cjs/index.cjs.js +3 -3
- package/dist/cjs/utils.cjs.js +1 -1
- package/dist/codeBlockHighlight.js +26 -2
- package/dist/codeBlockHighlight.js.map +1 -1
- package/dist/editor-content.min.css +1 -1
- package/dist/editor-output-pdf-email.css +1 -1
- package/dist/editor-output.js +1 -1
- package/dist/editor-stats.html +1 -1
- package/dist/index.js +3 -3
- package/dist/utils.js +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var CopyToClipboardButton = require('@bigbinary/neeto-molecules/CopyToClipboardB
|
|
|
10
10
|
var ramda = require('ramda');
|
|
11
11
|
var client = require('react-dom/client');
|
|
12
12
|
var injectCss = require('./chunk-da9ee471.cjs.js');
|
|
13
|
-
var utils = require('./chunk-
|
|
13
|
+
var utils = require('./chunk-de3ec26b.cjs.js');
|
|
14
14
|
var reactUtils = require('@bigbinary/neeto-commons-frontend/react-utils');
|
|
15
15
|
var Close = require('@bigbinary/neeto-icons/Close');
|
|
16
16
|
var Button = require('@bigbinary/neetoui/Button');
|
|
@@ -36,7 +36,7 @@ var Close__default = /*#__PURE__*/_interopDefaultLegacy(Close);
|
|
|
36
36
|
var Button__default = /*#__PURE__*/_interopDefaultLegacy(Button);
|
|
37
37
|
var Spinner__default = /*#__PURE__*/_interopDefaultLegacy(Spinner);
|
|
38
38
|
|
|
39
|
-
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))}";
|
|
39
|
+
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))}";
|
|
40
40
|
injectCss.n(css,{});
|
|
41
41
|
|
|
42
42
|
var ImagePreview = function ImagePreview(_ref) {
|
|
@@ -148,6 +148,7 @@ var EditorContent = function EditorContent(_ref) {
|
|
|
148
148
|
React.useEffect(function () {
|
|
149
149
|
injectCopyButtonToCodeBlocks();
|
|
150
150
|
bindImageClickListener();
|
|
151
|
+
utils.applyLineHighlighting(editorContentRef.current);
|
|
151
152
|
}, [content]);
|
|
152
153
|
return /*#__PURE__*/jsxRuntime.jsxs(jsxRuntime.Fragment, {
|
|
153
154
|
children: [/*#__PURE__*/jsxRuntime.jsx("div", _objectSpread({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditorContent.cjs.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,cAAQ,CAAC,IAAI,CAAC;IAAAC,UAAA,GAAAC,kCAAA,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,2BAAc,EAAE;IAAtBC,CAAC,GAAAF,eAAA,CAADE,CAAC,CAAA;AAET,EAAA,IAAMC,eAAe,GAAGC,YAAM,CAAC,IAAI,CAAC,CAAA;EAEpCC,4BAAiB,CAACF,eAAe,EAAE,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,SAAS,EAAES,8BAAU,CAAC2B,8BAAwB,EAAA0B,mCAAA,CAAA,EAAA,EAC3C9D,SAAS,EAAGA,SAAS,CACvB,CAAE;AACH+D,MAAAA,uBAAuB,EAAE;AACvBC,QAAAA,MAAM,EAAEpC,QAAQ,CAACH,WAAW,EAAEwC,sBAAgB,CAAA;AAChD,OAAA;KACI5C,EAAAA,UAAU,CACf,CAAC,EACD5C,mBAAmB,iBAClByB,cAAA,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,UAAI,CAAClD,aAAa,CAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"EditorContent.cjs.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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target", "allow", "allowfullscreen", "frameborder"]
|
|
12524
12524
|
};
|
|
12525
|
-
var CODE_BLOCK_REGEX = /<pre
|
|
12525
|
+
var CODE_BLOCK_REGEX = /<pre(?:\s+[^>]+)?><code(?:\s+class="language-([^"]*)")?>([\S\s]*?)<\/code><\/pre>/gim;
|
|
12526
12526
|
var VARIABLE_SPAN_REGEX = /<span data-variable="" [^>]*data-label="([^"]+)">{{([^}]+)}}<\/span>/g;
|
|
12527
12527
|
var LANGUAGE_LIST = [].concat(_toConsumableArray__default["default"](core.lowlight.listLanguages()), ["html"]);
|
|
12528
12528
|
|
|
12529
|
+
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; } } }; }
|
|
12530
|
+
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); }
|
|
12531
|
+
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; }
|
|
12529
12532
|
var transformCode = function transformCode(code) {
|
|
12530
12533
|
return code.replace(/>/g, ">").replace(/</g, "<").replace(/&/g, "&");
|
|
12531
12534
|
};
|
|
@@ -12536,10 +12539,58 @@ var buildReactElementFromAST = function buildReactElementFromAST(element) {
|
|
|
12536
12539
|
}
|
|
12537
12540
|
return element.value;
|
|
12538
12541
|
};
|
|
12542
|
+
var highlightLinesCode = function highlightLinesCode(code, options) {
|
|
12543
|
+
code.innerHTML = code.innerHTML.replace(/([ \S]*\n|[ \S]*$)/gm, function (match) {
|
|
12544
|
+
return "<div class=\"highlight-line\">".concat(match, "</div>");
|
|
12545
|
+
});
|
|
12546
|
+
if (options === undefined) {
|
|
12547
|
+
return;
|
|
12548
|
+
}
|
|
12549
|
+
var paddingLeft = parseInt(window.getComputedStyle(code).paddingLeft);
|
|
12550
|
+
var paddingRight = parseInt(window.getComputedStyle(code).paddingRight);
|
|
12551
|
+
var lines = code.getElementsByClassName("highlight-line");
|
|
12552
|
+
var scroll_width = code.scrollWidth;
|
|
12553
|
+
// eslint-disable-next-line @bigbinary/neeto/use-array-methods
|
|
12554
|
+
var _iterator = _createForOfIteratorHelper(options),
|
|
12555
|
+
_step;
|
|
12556
|
+
try {
|
|
12557
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
12558
|
+
var option = _step.value;
|
|
12559
|
+
for (var j = option.start; j <= option.end; ++j) {
|
|
12560
|
+
lines[j].style.backgroundColor = option.color;
|
|
12561
|
+
lines[j].style.minWidth = "".concat(scroll_width - paddingLeft - paddingRight, "px");
|
|
12562
|
+
}
|
|
12563
|
+
}
|
|
12564
|
+
} catch (err) {
|
|
12565
|
+
_iterator.e(err);
|
|
12566
|
+
} finally {
|
|
12567
|
+
_iterator.f();
|
|
12568
|
+
}
|
|
12569
|
+
};
|
|
12570
|
+
var highlightLinesElement = function highlightLinesElement(code, options) {
|
|
12571
|
+
// eslint-disable-next-line @bigbinary/neeto/use-array-methods
|
|
12572
|
+
var _iterator2 = _createForOfIteratorHelper(options),
|
|
12573
|
+
_step2;
|
|
12574
|
+
try {
|
|
12575
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
12576
|
+
var option = _step2.value;
|
|
12577
|
+
--option.start;
|
|
12578
|
+
--option.end;
|
|
12579
|
+
}
|
|
12580
|
+
} catch (err) {
|
|
12581
|
+
_iterator2.e(err);
|
|
12582
|
+
} finally {
|
|
12583
|
+
_iterator2.f();
|
|
12584
|
+
}
|
|
12585
|
+
highlightLinesCode(code, options);
|
|
12586
|
+
};
|
|
12539
12587
|
var highlightCode = function highlightCode(content) {
|
|
12540
12588
|
core.lowlight.highlightAuto("");
|
|
12541
12589
|
var highlightedAST = {};
|
|
12542
12590
|
return content.replace(CODE_BLOCK_REGEX, function (_, language, code) {
|
|
12591
|
+
var _match$;
|
|
12592
|
+
var regex = /data-highlighted-lines="([^"]*)"/;
|
|
12593
|
+
var match = content.match(regex);
|
|
12543
12594
|
if (language && LANGUAGE_LIST.includes(language)) {
|
|
12544
12595
|
highlightedAST = core.lowlight.highlight(language, transformCode(code));
|
|
12545
12596
|
} else {
|
|
@@ -12549,7 +12600,25 @@ var highlightCode = function highlightCode(content) {
|
|
|
12549
12600
|
}
|
|
12550
12601
|
}
|
|
12551
12602
|
var highlightedNode = highlightedAST.children.map(buildReactElementFromAST);
|
|
12552
|
-
return "<pre><code>".concat(server.renderToString(highlightedNode), "</code></pre>");
|
|
12603
|
+
return "<pre data-highlighted-lines=".concat((_match$ = match === null || match === void 0 ? void 0 : match[1]) !== null && _match$ !== void 0 ? _match$ : "", "><code>").concat(server.renderToString(highlightedNode), "</code></pre>");
|
|
12604
|
+
});
|
|
12605
|
+
};
|
|
12606
|
+
var applyLineHighlighting = function applyLineHighlighting(editorContent) {
|
|
12607
|
+
var codeTags = editorContent === null || editorContent === void 0 ? void 0 : editorContent.querySelectorAll("pre code");
|
|
12608
|
+
codeTags.forEach(function (codeTag) {
|
|
12609
|
+
var highlightedLines = codeTag.closest("pre").getAttribute("data-highlighted-lines");
|
|
12610
|
+
if (highlightedLines) {
|
|
12611
|
+
var _highlightedLines$spl;
|
|
12612
|
+
var linesToHighlight = (_highlightedLines$spl = highlightedLines.split(",")) === null || _highlightedLines$spl === void 0 ? void 0 : _highlightedLines$spl.map(Number);
|
|
12613
|
+
var highlightLinesOptions = linesToHighlight.map(function (line) {
|
|
12614
|
+
return {
|
|
12615
|
+
start: line,
|
|
12616
|
+
end: line,
|
|
12617
|
+
color: "rgba(255, 255, 0, 0.2)"
|
|
12618
|
+
};
|
|
12619
|
+
});
|
|
12620
|
+
highlightLinesElement(codeTag, highlightLinesOptions);
|
|
12621
|
+
}
|
|
12553
12622
|
});
|
|
12554
12623
|
};
|
|
12555
12624
|
var substituteVariables = function substituteVariables(highlightedContent, variables) {
|
|
@@ -12573,6 +12642,7 @@ var substituteVariables = function substituteVariables(highlightedContent, varia
|
|
|
12573
12642
|
|
|
12574
12643
|
exports.EDITOR_CONTENT_CLASSNAME = EDITOR_CONTENT_CLASSNAME;
|
|
12575
12644
|
exports.SANITIZE_OPTIONS = SANITIZE_OPTIONS;
|
|
12645
|
+
exports.applyLineHighlighting = applyLineHighlighting;
|
|
12576
12646
|
exports.highlightCode = highlightCode;
|
|
12577
12647
|
exports.substituteVariables = substituteVariables;
|
|
12578
|
-
//# sourceMappingURL=chunk-
|
|
12648
|
+
//# sourceMappingURL=chunk-de3ec26b.cjs.js.map
|