Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

bandicoot

Package Overview
Dependencies
Maintainers
5
Versions
56
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bandicoot - npm Package Compare versions

Comparing version 3.0.1 to 3.0.2

2

dist/bandicoot.esm.js

@@ -1,2 +0,2 @@

import React,{useRef,useEffect,forwardRef,useContext,useState}from"react";function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(b,!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function RichTextContainer(a){const b=useRef(Object.assign({},defaultContextValue)),c=b.current,d=useRef([]),e=useRef([]),f=useRef([]),g=useRef([]);return useEffect(()=>{const a=c.getContentEditableElement();a&&a.innerHTML&&c.fireNewHTML()},[c]),c.addSelectionChangedListener=a=>{d.current.push(a)},c.removeSelectionChangedListener=a=>{d.current=d.current.filter(b=>b!==a)},c.fireSelectionChanged=()=>{d.current.forEach(a=>a())},c.addBlurListener=a=>{e.current.push(a)},c.removeBlurListener=a=>{e.current=e.current.filter(b=>b!==a)},c.fireBlur=()=>{e.current.forEach(a=>a())},c.addNewHTMLListener=a=>{f.current.push(a)},c.removeNewHTMLListener=a=>{f.current=f.current.filter(b=>b!==a)},c.fireNewHTML=()=>{f.current.forEach(a=>a())},c.numSerializers=()=>g.current.length,c.addSerializer=a=>{g.current.push(a)},c.removeSerializer=a=>{g.current=g.current.filter(b=>b!==a)},c.serialize=a=>(g.current.forEach(b=>b(a)),a.innerHTML),React.createElement(RichTextContext.Provider,{value:c},a.children)}const noop=()=>{},defaultContextValue={addSelectionChangedListener:noop,removeSelectionChangedListener:noop,fireSelectionChanged:noop,selectRangeFromBeforeBlur:noop,getRangeBeforeBlur:noop,addBlurListener:noop,removeBlurListener:noop,fireBlur:noop,addNewHTMLListener:noop,removeNewHTMLListener:noop,fireNewHTML:noop,isFocused:noop,getContentEditableElement:noop,numSerializers:()=>0,addSerializer:noop,removeSerializer:noop,serialize:noop,sanitizeHTML:noop},RichTextContext=React.createContext(defaultContextValue),noop$1=()=>{},noopWithReturn=a=>a;let globalBandicootId=0;const RichTextEditor=forwardRef((a,b)=>{function c(b){b.preventDefault(),b.stopPropagation();let c=l.sanitizeHTML((window.clipboardData||b.clipboardData).getData("text/html"),"pasteHTML"),d=a.pasteFn(c);!1!==d&&document.execCommand("insertHTML",null,d)}function d(){const a=document.createRange();a.selectNodeContents(m.current);const b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("removeFormat"),document.execCommand("delete")}function e(){if(o()){const a=window.getSelection();0<a.rangeCount&&(n.current=window.getSelection().getRangeAt(0)),l.fireSelectionChanged()}}function f(){const b=i();b!==r&&(s(b),a.save(b))}function g(){let a=m.current.innerHTML;if(0<l.numSerializers()){const b=new DOMParser().parseFromString(a,"text/html");a=l.serialize(b.body)}return a}function h(a){d(),m.current.innerHTML=l.sanitizeHTML(a,"setHTML"),j(),l.fireNewHTML()}function i(){return l.sanitizeHTML(g(),"getHTML")}function j(){m.current.focus(),p(!0)}function k(){return a.placeholderColor?"color: ".concat(a.placeholderColor,";"):window.chrome&&(window.chrome.webstore||window.chrome.runtime)?"color: rgb(117, 117, 117);":"opacity: 0.54;"}if("function"!=typeof a.sanitizeHTML)throw Error("RichTextEditor must be passed a sanitizeHTML function as a prop");const l=useContext(RichTextContext);l.sanitizeHTML=a.sanitizeHTML;const m=useRef(null),n=useRef(null),{isFocused:o,setFocused:p}=useSynchronousFocusState(),q=useRef(globalBandicootId++),[r,s]=useState(()=>l.sanitizeHTML(a.initialHTML,"initialSetLastSavedHTML")),[t,u]=useState(!1);b&&(b.current={setHTML:h,resetEditor:function(){h("")},getHTML:i,focus:j}),useEffect(()=>(m.current.addEventListener("paste",c),()=>m.current.removeEventListener("paste",c)),[a.pasteFn]),useEffect(()=>(document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e))),useEffect(()=>{if(a.save&&a.unchangedInterval&&m.current&&o()){let b;const c=new MutationObserver(()=>{clearTimeout(b),b=setTimeout(f,a.unchangedInterval)});return c.observe(m.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{c.disconnect(),clearTimeout(b)}}},[a.unchangedInterval,a.save,m.current,o()]),useEffect(()=>{if(!1===o()){const a=setTimeout(()=>{l.fireBlur(),f()},100);return()=>{clearTimeout(a)}}},[o()]),useEffect(()=>{l.selectRangeFromBeforeBlur=function(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{usePreviousRange:!1};if(m.current&&document.activeElement!==m.current&&!m.current.contains(document.activeElement)){if(a.usePreviousRange&&n.current){const a=window.getSelection();a.removeAllRanges(),a.addRange(n.current)}else m.current.focus();p(!0),setTimeout(e)}},l.getRangeFromBeforeBlur=()=>n.current,l.isFocused=o,l.getContentEditableElement=()=>m.current}),useEffect(()=>{!t&&a.initialHTML&&(u(!0),h(a.initialHTML))},[t,h,l]),useEffect(()=>{if(a.placeholder){const a=document.createElement("style");return a.textContent=".bandicoot-id-".concat(q.current,":empty:before { content: attr(data-placeholder); ").concat(k()," }"),document.head.appendChild(a),()=>a.parentNode.removeChild(a)}},[a.placeholder,a.placeholderColor,q.current]);const v=a.style||{};return React.createElement("div",{contentEditable:!a.disabled,onBlur:()=>p(!1),onFocus:function(){p(!0);const a=window.getSelection();0<a.rangeCount&&(n.current=a.getRangeAt(0))},ref:m,className:a.className+" bandicoot-id-"+q.current,style:_objectSpread2({wordBreak:"break-word",wordWrap:"break-word",overflowWrap:"break-word"},v),"data-placeholder":a.placeholder})});function useSynchronousFocusState(){const a=useRef(null),[b,c]=useState(!1);return{isFocused:function(){return a.current},setFocused:function(d){a.current=d,c(!b)}}}RichTextEditor.defaultProps={className:"",initialHTML:"",save:noop$1,placeholder:"",pasteFn:noopWithReturn};function useDocumentExecCommand(a){const b=useContext(RichTextContext);return{performCommand(c){b.selectRangeFromBeforeBlur(),document.execCommand(a)},performCommandWithValue(c){b.selectRangeFromBeforeBlur();document.execCommand(a,null,c)}}}function useFormatBlock(){const{performCommandWithValue:a}=useDocumentExecCommand("formatBlock");return{formatBlock(b){b===document.queryCommandValue("formatBlock")?a("div"):a(b)}}}const defaultActiveInfo={isActive:!1,value:!1};function useDocumentQueryCommandState(a,b){function c(){const c=document.queryCommandValue(a),d=b?b===c:document.queryCommandState(a);(d!==e.isActive||c!==e.value)&&f({isActive:d,value:c})}function d(){f(defaultActiveInfo)}const[e,f]=useState(defaultActiveInfo),g=useContext(RichTextContext);return useEffect(()=>(g.addSelectionChangedListener(c),()=>g.removeSelectionChangedListener(c)),[e,f]),useEffect(()=>(g.addBlurListener(d),()=>g.removeBlurListener(d)),[e,f]),{isActive:e.isActive,activeValue:e.value}}function useFontSize(a){let{defaultFontSize:c="14px",fontSizes:b}=a;if(7<b.length)throw Error("Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)");const[d,e]=useState(c),[f,g]=useState(null),{performCommandWithValue:h}=useDocumentExecCommand("fontSize"),i=useContext(RichTextContext),j=function(){return useEffect(()=>{function a(){const a=window.getSelection();if((!f||a.anchorNode!==f.anchorNode||a.anchorOffset!==f.anchorOffset||a.focusNode!==f.focusNode||a.focusOffset!==f.focusOffset)&&(g({anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),0<a.rangeCount)){let b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);const c=window.getComputedStyle(b).fontSize,f=c;f!==d&&e(f)}}return i.addSelectionChangedListener(a),()=>i.removeSelectionChangedListener(a)},[d,e,f]),d}();return function(){useEffect(()=>{const a=b.reduce((a,b,c)=>"".concat(a," font[size=\"").concat(c+1,"\"] {font-size: ").concat(b,"}"),""),c=document.createElement("style");return c.textContent=a,document.head.appendChild(c),()=>document.head.removeChild(c)},[b]),useEffect(()=>{function a(a){const c=a.querySelectorAll("font");for(let d=0;d<c.length;d++){const a=c[d],e=+a.getAttribute("size");if(e>b.length)throw Error("Cannot find fontSize for integer size '".concat(e,"'"));const f=b[e-1];a.removeAttribute("size"),a.style.fontSize=f,a.dataset.integerSize=e}}return i.addSerializer(a),()=>i.removeSerializer(a)},[b]),useEffect(()=>{function a(){const a=i.getContentEditableElement().querySelectorAll("font");for(let c=0;c<a.length;c++){const d=a[c],e=d.style.fontSize,f=b.findIndex(a=>a===e)+1;0<f&&(d.style.fontSize="",d.setAttribute("size",f))}}return i.addNewHTMLListener(a),()=>i.removeNewHTMLListener(a)},[b])}(),{currentlySelectedFontSize:j,setSize(a){const c=b.findIndex(b=>b===a)+1;if(0>=c)throw Error("Cannot set font size since '".concat(a,"' was not passed in the fontSizes array"));e(a),h(c)}}}const noop$2=()=>{},defaultAcceptImgTypes=".jpg, .png, image/*",defaultOpts={processImgElement:noop$2,fileBlobToUrl:defaultFileBlobToUrl,acceptImgTypes:defaultAcceptImgTypes};function useImage(){function a(a){a.style.cursor="pointer",a.style.maxWidth="100%",c(a)}function b(a){a.querySelectorAll("img").forEach(a=>{i.current[a.src]&&(a.src=i.current[a.src])})}let{processImgElement:c=noop$2,fileBlobToUrl:d=defaultFileBlobToUrl,acceptImgTypes:e=defaultAcceptImgTypes}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOpts;const{performCommandWithValue:f}=useDocumentExecCommand("insertImage"),g=useContext(RichTextContext),h=useRef(null),i=React.useRef({});return function(){useEffect(()=>{function b(){const b=g.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return g.addNewHTMLListener(b),()=>g.removeNewHTMLListener(b)},[c])}(),function(){useEffect(()=>{h.current=document.createElement("input");const b=h.current;b.type="file",b.accept=e,b.multiple=!1,b.addEventListener("change",()=>{b.files&&0<b.files.length&&d(b.files[0],c=>{f(c);const d=document.querySelector("img[src=\"".concat(c,"\"]"));if(d.src&&d.src.startsWith("blob:")){const a=new FileReader;a.addEventListener("load",()=>{i.current[d.src]=a.result}),a.readAsDataURL(b.files[0])}a(d)})})},[d,c,e])}(),function(){useEffect(()=>(g.addSerializer(b),()=>g.removeSerializer(b)))}(),{chooseFile(a){h.current.click()},removeImage(a){const b=document.createRange();b.selectNode(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}}function defaultFileBlobToUrl(a,b){b(URL.createObjectURL(a))}let tempId=0;const noop$3=()=>{},defaultOptions={processAnchorElement:noop$3};function useLink(){function a(a,d){c.selectRangeFromBeforeBlur({usePreviousRange:!0});const f="rte-link-temp-id-".concat(tempId++);e("<a href=\"".concat(a,"\" id=\"").concat(f,"\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(d,"</a>"));const g=document.getElementById(f);g.removeAttribute("id"),b(g)}let{processAnchorElement:b=noop$3}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions;const c=useContext(RichTextContext),{performCommand:d}=useDocumentExecCommand("unlink"),{performCommandWithValue:e}=useDocumentExecCommand("insertHTML");return function(){useEffect(()=>{function a(){const a=c.getContentEditableElement().querySelectorAll("a");a.forEach(b)}return c.addNewHTMLListener(a),()=>c.removeNewHTMLListener(a)},[b])}(),{getTextFromBeforeBlur:function(){const a=c.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){const b=document.createRange();b.selectNodeContents(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:function(){d(),(window.navigator.userAgent.includes("Edge/14")||window.navigator.userAgent.includes("Edge/15")||window.navigator.userAgent.includes("Edge/16")||window.navigator.userAgent.includes("Edge/17"))&&document.execCommand("removeFormat")},insertLink:a}}let tempId$1=0;const noop$4=()=>{},defaultOptions$1={processContentEditableFalseElement:noop$4};function useContentEditableFalse(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>selectRangeAfterNode(a)),!a.previousSibling&&a.parentElement===d.getContentEditableElement()){const b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===d.getContentEditableElement()){const b=document.createElement("span");a.insertAdjacentElement("afterend",b)}selectRangeAfterNode(a),b(a)}let{processContentEditableFalseElement:b=noop$4}=0<arguments.length&&arguments[0]!==void 0?arguments[0]:defaultOptions$1;const{performCommandWithValue:c}=useDocumentExecCommand("insertHTML"),d=useContext(RichTextContext);return{insertContentEditableFalseElement(b){const e="rte-ce-false-temp-id-"+tempId$1++,f="<span id=\"".concat(e,"\">").concat(d.sanitizeHTML(b,"insertContentEditableFalseHTML"),"</span>");c(f);const g=document.getElementById(e);a(g)}}}function selectRangeAfterNode(a){const b=document.createRange();b.setStartAfter(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)}const noop$5=()=>{},defaultOptions$2={processSerializedElement:noop$5,fontFamily:null};function useTextAsImage(){let{processSerializedElement:a=noop$5,fontFamily:b=null}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions$2;const{performCommandWithValue:c}=useDocumentExecCommand("insertImage"),d=useContext(RichTextContext);return function(){useEffect(()=>{function a(){const a=d.getContentEditableElement().querySelectorAll("span[data-text-as-image]");for(let c=0;c<a.length;c++){const d=a[c],e=textToUrl(d.dataset.textAsImage,d.previousElementSibling||d.nextElementSibling||d.parentElement,b),f=document.createElement("img");f.src=e,processImgElement(f,d.dataset.textAsImage),d.parentNode.replaceChild(f,d)}}return d.addNewHTMLListener(a),()=>d.removeNewHTMLListener(a)},[])}(),function(){useEffect(()=>{function b(b){const c=b.querySelectorAll("img[data-text-as-image]");for(let d=0;d<c.length;d++){const b=c[d],e=document.createElement("span");e.dataset.textAsImage=b.dataset.textAsImage,a(e,e.dataset.textAsImage),b.parentNode.replaceChild(e,b)}}return d.addSerializer(b),()=>d.removeSerializer(b)},[])}(),{insertTextAsImage(a){d.selectRangeFromBeforeBlur({usePreviousRange:!0});const e=textToUrl(a,getSelectedElement(),b);c(e);const f=document.querySelector("img[src=\"".concat(e,"\"]"));processImgElement(f,a)}}}function textToUrl(a,b,d){const e=window.getComputedStyle(b),f=+e.fontSize.replace("px",""),g=+e.lineHeight.replace("px",""),h=d||e.fontFamily,i="bold ".concat(f,"px ").concat(h),j=document.createElement("div");j.style.font=i,j.style.position="absolute",j.style.visibility="hidden",j.style.whiteSpace="nowrap",j.textContent=a,document.body.appendChild(j);const k=document.createElement("canvas");k.width=j.clientWidth+1,k.height=g;const l=k.getContext("2d");return l.font=i,l.fillStyle="#00bf4b",l.textBaseline="bottom",l.fillText(a,0,g-3),document.body.removeChild(j),l.canvas.toDataURL()}function processImgElement(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{const c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);const f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function getSelectedElement(){let a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}function useElementDeletionDetection(a,b){const c=useContext(RichTextContext);useEffect(()=>{if(a){function d(){a.isConnected||a._bandicoot_delete_callback_called||(a._bandicoot_delete_callback_called=!0,b(a))}return c.addSelectionChangedListener(d),()=>c.removeSelectionChangedListener(d)}},[a,b])}export{RichTextContainer,RichTextContext,RichTextEditor,useContentEditableFalse,useDocumentExecCommand,useDocumentQueryCommandState,useElementDeletionDetection,useFontSize,useFormatBlock,useImage,useLink,useTextAsImage};
import React,{useRef,useEffect,forwardRef,useContext,useState}from"react";function _defineProperty(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread2(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(b,!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function RichTextContainer(a){const b=useRef(Object.assign({},defaultContextValue)),c=b.current,d=useRef([]),e=useRef([]),f=useRef([]),g=useRef([]);return useEffect(()=>{const a=c.getContentEditableElement();a&&a.innerHTML&&c.fireNewHTML()},[c]),c.addSelectionChangedListener=a=>{d.current.push(a)},c.removeSelectionChangedListener=a=>{d.current=d.current.filter(b=>b!==a)},c.fireSelectionChanged=()=>{d.current.forEach(a=>a())},c.addBlurListener=a=>{e.current.push(a)},c.removeBlurListener=a=>{e.current=e.current.filter(b=>b!==a)},c.fireBlur=()=>{e.current.forEach(a=>a())},c.addNewHTMLListener=a=>{f.current.push(a)},c.removeNewHTMLListener=a=>{f.current=f.current.filter(b=>b!==a)},c.fireNewHTML=()=>{f.current.forEach(a=>a())},c.numSerializers=()=>g.current.length,c.addSerializer=a=>{g.current.push(a)},c.removeSerializer=a=>{g.current=g.current.filter(b=>b!==a)},c.serialize=a=>(g.current.forEach(b=>b(a)),a.innerHTML),React.createElement(RichTextContext.Provider,{value:c},a.children)}const noop=()=>{},defaultContextValue={addSelectionChangedListener:noop,removeSelectionChangedListener:noop,fireSelectionChanged:noop,selectRangeFromBeforeBlur:noop,getRangeBeforeBlur:noop,addBlurListener:noop,removeBlurListener:noop,fireBlur:noop,addNewHTMLListener:noop,removeNewHTMLListener:noop,fireNewHTML:noop,isFocused:noop,getContentEditableElement:noop,numSerializers:()=>0,addSerializer:noop,removeSerializer:noop,serialize:noop,sanitizeHTML:noop},RichTextContext=React.createContext(defaultContextValue),noop$1=()=>{},noopWithReturn=a=>a;let globalBandicootId=0;const RichTextEditor=forwardRef((a,b)=>{function c(b){b.preventDefault(),b.stopPropagation();let c=l.sanitizeHTML((window.clipboardData||b.clipboardData).getData("text/html"),"pasteHTML"),d=a.pasteFn(c);!1!==d&&document.execCommand("insertHTML",null,d)}function d(){const a=document.createRange();a.selectNodeContents(m.current);const b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("removeFormat"),document.execCommand("delete")}function e(){if(o()){const a=window.getSelection();0<a.rangeCount&&(n.current=window.getSelection().getRangeAt(0)),l.fireSelectionChanged()}}function f(){const b=i();b!==r&&(s(b),a.save(b))}function g(){let a=m.current.innerHTML;if(0<l.numSerializers()){const b=new DOMParser().parseFromString(a,"text/html");a=l.serialize(b.body)}return a}function h(b,c){c?(m.current.innerHTML=l.sanitizeHTML(b,"setHTML"),a.autoFocus&&j()):(d(),m.current.innerHTML=l.sanitizeHTML(b,"setHTML"),j()),l.fireNewHTML()}function i(){return l.sanitizeHTML(g(),"getHTML")}function j(){m.current.focus(),p(!0)}function k(){return a.placeholderColor?"color: ".concat(a.placeholderColor,";"):window.chrome&&(window.chrome.webstore||window.chrome.runtime)?"color: rgb(117, 117, 117);":"opacity: 0.54;"}if("function"!=typeof a.sanitizeHTML)throw Error("RichTextEditor must be passed a sanitizeHTML function as a prop");const l=useContext(RichTextContext);l.sanitizeHTML=a.sanitizeHTML;const m=useRef(null),n=useRef(null),{isFocused:o,setFocused:p}=useSynchronousFocusState(),q=useRef(globalBandicootId++),[r,s]=useState(()=>l.sanitizeHTML(a.initialHTML,"initialSetLastSavedHTML")),[t,u]=useState(!1);b&&(b.current={setHTML:h,resetEditor:function(){h("")},getHTML:i,focus:j}),useEffect(()=>(m.current.addEventListener("paste",c),()=>m.current.removeEventListener("paste",c)),[a.pasteFn]),useEffect(()=>(document.addEventListener("selectionchange",e),()=>document.removeEventListener("selectionchange",e))),useEffect(()=>{if(a.save&&a.unchangedInterval&&m.current&&o()){let b;const c=new MutationObserver(()=>{clearTimeout(b),b=setTimeout(f,a.unchangedInterval)});return c.observe(m.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{c.disconnect(),clearTimeout(b)}}},[a.unchangedInterval,a.save,m.current,o()]),useEffect(()=>{if(!1===o()){const a=setTimeout(()=>{l.fireBlur(),f()},100);return()=>{clearTimeout(a)}}},[o()]),useEffect(()=>{l.selectRangeFromBeforeBlur=function(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{usePreviousRange:!1};if(m.current&&document.activeElement!==m.current&&!m.current.contains(document.activeElement)){if(a.usePreviousRange&&n.current){const a=window.getSelection();a.removeAllRanges(),a.addRange(n.current)}else m.current.focus();p(!0),setTimeout(e)}},l.getRangeFromBeforeBlur=()=>n.current,l.isFocused=o,l.getContentEditableElement=()=>m.current}),useEffect(()=>{!t&&a.initialHTML&&(u(!0),h(a.initialHTML,!0))},[t,h,l]),useEffect(()=>{if(a.placeholder){const a=document.createElement("style");return a.textContent=".bandicoot-id-".concat(q.current,":empty:before { content: attr(data-placeholder); ").concat(k()," }"),document.head.appendChild(a),()=>a.parentNode.removeChild(a)}},[a.placeholder,a.placeholderColor,q.current]);const v=a.style||{};return React.createElement("div",{contentEditable:!a.disabled,onBlur:()=>p(!1),onFocus:function(){p(!0);const a=window.getSelection();0<a.rangeCount&&(n.current=a.getRangeAt(0))},ref:m,className:a.className+" bandicoot-id-"+q.current,style:_objectSpread2({wordBreak:"break-word",wordWrap:"break-word",overflowWrap:"break-word"},v),"data-placeholder":a.placeholder})});function useSynchronousFocusState(){const a=useRef(null),[b,c]=useState(!1);return{isFocused:function(){return a.current},setFocused:function(d){a.current=d,c(!b)}}}RichTextEditor.defaultProps={className:"",initialHTML:"",save:noop$1,placeholder:"",pasteFn:noopWithReturn};function useDocumentExecCommand(a){const b=useContext(RichTextContext);return{performCommand(c){b.selectRangeFromBeforeBlur(),document.execCommand(a)},performCommandWithValue(c){b.selectRangeFromBeforeBlur();document.execCommand(a,null,c)}}}function useFormatBlock(){const{performCommandWithValue:a}=useDocumentExecCommand("formatBlock");return{formatBlock(b){b===document.queryCommandValue("formatBlock")?a("div"):a(b)}}}const defaultActiveInfo={isActive:!1,value:!1};function useDocumentQueryCommandState(a,b){function c(){const c=document.queryCommandValue(a),d=b?b===c:document.queryCommandState(a);(d!==e.isActive||c!==e.value)&&f({isActive:d,value:c})}function d(){f(defaultActiveInfo)}const[e,f]=useState(defaultActiveInfo),g=useContext(RichTextContext);return useEffect(()=>(g.addSelectionChangedListener(c),()=>g.removeSelectionChangedListener(c)),[e,f]),useEffect(()=>(g.addBlurListener(d),()=>g.removeBlurListener(d)),[e,f]),{isActive:e.isActive,activeValue:e.value}}function useFontSize(a){let{defaultFontSize:c="14px",fontSizes:b}=a;if(7<b.length)throw Error("Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)");const[d,e]=useState(c),[f,g]=useState(null),{performCommandWithValue:h}=useDocumentExecCommand("fontSize"),i=useContext(RichTextContext),j=function(){return useEffect(()=>{function a(){const a=window.getSelection();if((!f||a.anchorNode!==f.anchorNode||a.anchorOffset!==f.anchorOffset||a.focusNode!==f.focusNode||a.focusOffset!==f.focusOffset)&&(g({anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),0<a.rangeCount)){let b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);const c=window.getComputedStyle(b).fontSize,f=c;f!==d&&e(f)}}return i.addSelectionChangedListener(a),()=>i.removeSelectionChangedListener(a)},[d,e,f]),d}();return function(){useEffect(()=>{const a=b.reduce((a,b,c)=>"".concat(a," font[size=\"").concat(c+1,"\"] {font-size: ").concat(b,"}"),""),c=document.createElement("style");return c.textContent=a,document.head.appendChild(c),()=>document.head.removeChild(c)},[b]),useEffect(()=>{function a(a){const c=a.querySelectorAll("font");for(let d=0;d<c.length;d++){const a=c[d],e=+a.getAttribute("size");if(e>b.length)throw Error("Cannot find fontSize for integer size '".concat(e,"'"));const f=b[e-1];a.removeAttribute("size"),a.style.fontSize=f,a.dataset.integerSize=e}}return i.addSerializer(a),()=>i.removeSerializer(a)},[b]),useEffect(()=>{function a(){const a=i.getContentEditableElement().querySelectorAll("font");for(let c=0;c<a.length;c++){const d=a[c],e=d.style.fontSize,f=b.findIndex(a=>a===e)+1;0<f&&(d.style.fontSize="",d.setAttribute("size",f))}}return i.addNewHTMLListener(a),()=>i.removeNewHTMLListener(a)},[b])}(),{currentlySelectedFontSize:j,setSize(a){const c=b.findIndex(b=>b===a)+1;if(0>=c)throw Error("Cannot set font size since '".concat(a,"' was not passed in the fontSizes array"));e(a),h(c)}}}const noop$2=()=>{},defaultAcceptImgTypes=".jpg, .png, image/*",defaultOpts={processImgElement:noop$2,fileBlobToUrl:defaultFileBlobToUrl,acceptImgTypes:defaultAcceptImgTypes};function useImage(){function a(a){a.style.cursor="pointer",a.style.maxWidth="100%",c(a)}function b(a){a.querySelectorAll("img").forEach(a=>{i.current[a.src]&&(a.src=i.current[a.src])})}let{processImgElement:c=noop$2,fileBlobToUrl:d=defaultFileBlobToUrl,acceptImgTypes:e=defaultAcceptImgTypes}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOpts;const{performCommandWithValue:f}=useDocumentExecCommand("insertImage"),g=useContext(RichTextContext),h=useRef(null),i=React.useRef({});return function(){useEffect(()=>{function b(){const b=g.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return g.addNewHTMLListener(b),()=>g.removeNewHTMLListener(b)},[c])}(),function(){useEffect(()=>{h.current=document.createElement("input");const b=h.current;b.type="file",b.accept=e,b.multiple=!1,b.addEventListener("change",()=>{b.files&&0<b.files.length&&d(b.files[0],c=>{f(c);const d=document.querySelector("img[src=\"".concat(c,"\"]"));if(d.src&&d.src.startsWith("blob:")){const a=new FileReader;a.addEventListener("load",()=>{i.current[d.src]=a.result}),a.readAsDataURL(b.files[0])}a(d)})})},[d,c,e])}(),function(){useEffect(()=>(g.addSerializer(b),()=>g.removeSerializer(b)))}(),{chooseFile(a){h.current.click()},removeImage(a){const b=document.createRange();b.selectNode(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}}function defaultFileBlobToUrl(a,b){b(URL.createObjectURL(a))}let tempId=0;const noop$3=()=>{},defaultOptions={processAnchorElement:noop$3};function useLink(){function a(a,d){c.selectRangeFromBeforeBlur({usePreviousRange:!0});const f="rte-link-temp-id-".concat(tempId++);e("<a href=\"".concat(a,"\" id=\"").concat(f,"\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(d,"</a>"));const g=document.getElementById(f);g.removeAttribute("id"),b(g)}let{processAnchorElement:b=noop$3}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions;const c=useContext(RichTextContext),{performCommand:d}=useDocumentExecCommand("unlink"),{performCommandWithValue:e}=useDocumentExecCommand("insertHTML");return function(){useEffect(()=>{function a(){const a=c.getContentEditableElement().querySelectorAll("a");a.forEach(b)}return c.addNewHTMLListener(a),()=>c.removeNewHTMLListener(a)},[b])}(),{getTextFromBeforeBlur:function(){const a=c.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){const b=document.createRange();b.selectNodeContents(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:function(){d(),(window.navigator.userAgent.includes("Edge/14")||window.navigator.userAgent.includes("Edge/15")||window.navigator.userAgent.includes("Edge/16")||window.navigator.userAgent.includes("Edge/17"))&&document.execCommand("removeFormat")},insertLink:a}}let tempId$1=0;const noop$4=()=>{},defaultOptions$1={processContentEditableFalseElement:noop$4};function useContentEditableFalse(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>selectRangeAfterNode(a)),!a.previousSibling&&a.parentElement===d.getContentEditableElement()){const b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===d.getContentEditableElement()){const b=document.createElement("span");a.insertAdjacentElement("afterend",b)}selectRangeAfterNode(a),b(a)}let{processContentEditableFalseElement:b=noop$4}=0<arguments.length&&arguments[0]!==void 0?arguments[0]:defaultOptions$1;const{performCommandWithValue:c}=useDocumentExecCommand("insertHTML"),d=useContext(RichTextContext);return{insertContentEditableFalseElement(b){const e="rte-ce-false-temp-id-"+tempId$1++,f="<span id=\"".concat(e,"\">").concat(d.sanitizeHTML(b,"insertContentEditableFalseHTML"),"</span>");c(f);const g=document.getElementById(e);a(g)}}}function selectRangeAfterNode(a){const b=document.createRange();b.setStartAfter(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)}const noop$5=()=>{},defaultOptions$2={processSerializedElement:noop$5,fontFamily:null};function useTextAsImage(){let{processSerializedElement:a=noop$5,fontFamily:b=null}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:defaultOptions$2;const{performCommandWithValue:c}=useDocumentExecCommand("insertImage"),d=useContext(RichTextContext);return function(){useEffect(()=>{function a(){const a=d.getContentEditableElement().querySelectorAll("span[data-text-as-image]");for(let c=0;c<a.length;c++){const d=a[c],e=textToUrl(d.dataset.textAsImage,d.previousElementSibling||d.nextElementSibling||d.parentElement,b),f=document.createElement("img");f.src=e,processImgElement(f,d.dataset.textAsImage),d.parentNode.replaceChild(f,d)}}return d.addNewHTMLListener(a),()=>d.removeNewHTMLListener(a)},[])}(),function(){useEffect(()=>{function b(b){const c=b.querySelectorAll("img[data-text-as-image]");for(let d=0;d<c.length;d++){const b=c[d],e=document.createElement("span");e.dataset.textAsImage=b.dataset.textAsImage,a(e,e.dataset.textAsImage),b.parentNode.replaceChild(e,b)}}return d.addSerializer(b),()=>d.removeSerializer(b)},[])}(),{insertTextAsImage(a){d.selectRangeFromBeforeBlur({usePreviousRange:!0});const e=textToUrl(a,getSelectedElement(),b);c(e);const f=document.querySelector("img[src=\"".concat(e,"\"]"));processImgElement(f,a)}}}function textToUrl(a,b,d){const e=window.getComputedStyle(b),f=+e.fontSize.replace("px",""),g=+e.lineHeight.replace("px",""),h=d||e.fontFamily,i="bold ".concat(f,"px ").concat(h),j=document.createElement("div");j.style.font=i,j.style.position="absolute",j.style.visibility="hidden",j.style.whiteSpace="nowrap",j.textContent=a,document.body.appendChild(j);const k=document.createElement("canvas");k.width=j.clientWidth+1,k.height=g;const l=k.getContext("2d");return l.font=i,l.fillStyle="#00bf4b",l.textBaseline="bottom",l.fillText(a,0,g-3),document.body.removeChild(j),l.canvas.toDataURL()}function processImgElement(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{const c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);const f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function getSelectedElement(){let a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}function useElementDeletionDetection(a,b){const c=useContext(RichTextContext);useEffect(()=>{if(a){function d(){a.isConnected||a._bandicoot_delete_callback_called||(a._bandicoot_delete_callback_called=!0,b(a))}return c.addSelectionChangedListener(d),()=>c.removeSelectionChangedListener(d)}},[a,b])}export{RichTextContainer,RichTextContext,RichTextEditor,useContentEditableFalse,useDocumentExecCommand,useDocumentQueryCommandState,useElementDeletionDetection,useFontSize,useFormatBlock,useImage,useLink,useTextAsImage};
//# sourceMappingURL=bandicoot.esm.js.map

@@ -1,2 +0,2 @@

(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],b):(a=a||self,b(a.bandicoot={},a.React))})(this,function(a,b){'use strict';function c(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function d(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function e(a){for(var b,e=1;e<arguments.length;e++)b=null==arguments[e]?{}:arguments[e],e%2?d(b,!0).forEach(function(d){c(a,d,b[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):d(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function f(){const a=b.useRef(null),[c,d]=b.useState(!1);return{isFocused:function(){return a.current},setFocused:function(b){a.current=b,d(!c)}}}function g(a){const c=b.useContext(p);return{performCommand(b){c.selectRangeFromBeforeBlur(),document.execCommand(a)},performCommandWithValue(b){c.selectRangeFromBeforeBlur();document.execCommand(a,null,b)}}}function h(a,b){b(URL.createObjectURL(a))}function i(a){const b=document.createRange();b.setStartAfter(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)}function j(a,b,d){const e=window.getComputedStyle(b),f=+e.fontSize.replace("px",""),g=+e.lineHeight.replace("px",""),h=d||e.fontFamily,i="bold ".concat(f,"px ").concat(h),j=document.createElement("div");j.style.font=i,j.style.position="absolute",j.style.visibility="hidden",j.style.whiteSpace="nowrap",j.textContent=a,document.body.appendChild(j);const k=document.createElement("canvas");k.width=j.clientWidth+1,k.height=g;const l=k.getContext("2d");return l.font=i,l.fillStyle="#00bf4b",l.textBaseline="bottom",l.fillText(a,0,g-3),document.body.removeChild(j),l.canvas.toDataURL()}function k(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{const c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);const f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function l(){let a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}var m="default"in b?b["default"]:b;const n=()=>{},o={addSelectionChangedListener:n,removeSelectionChangedListener:n,fireSelectionChanged:n,selectRangeFromBeforeBlur:n,getRangeBeforeBlur:n,addBlurListener:n,removeBlurListener:n,fireBlur:n,addNewHTMLListener:n,removeNewHTMLListener:n,fireNewHTML:n,isFocused:n,getContentEditableElement:n,numSerializers:()=>0,addSerializer:n,removeSerializer:n,serialize:n,sanitizeHTML:n},p=m.createContext(o);let q=0;const r=b.forwardRef((a,c)=>{function d(b){b.preventDefault(),b.stopPropagation();let c=r.sanitizeHTML((window.clipboardData||b.clipboardData).getData("text/html"),"pasteHTML"),d=a.pasteFn(c);!1!==d&&document.execCommand("insertHTML",null,d)}function g(){const a=document.createRange();a.selectNodeContents(s.current);const b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("removeFormat"),document.execCommand("delete")}function h(){if(u()){const a=window.getSelection();0<a.rangeCount&&(t.current=window.getSelection().getRangeAt(0)),r.fireSelectionChanged()}}function i(){const b=l();b!==x&&(y(b),a.save(b))}function j(){let a=s.current.innerHTML;if(0<r.numSerializers()){const b=new DOMParser().parseFromString(a,"text/html");a=r.serialize(b.body)}return a}function k(a){g(),s.current.innerHTML=r.sanitizeHTML(a,"setHTML"),n(),r.fireNewHTML()}function l(){return r.sanitizeHTML(j(),"getHTML")}function n(){s.current.focus(),v(!0)}function o(){return a.placeholderColor?"color: ".concat(a.placeholderColor,";"):window.chrome&&(window.chrome.webstore||window.chrome.runtime)?"color: rgb(117, 117, 117);":"opacity: 0.54;"}if("function"!=typeof a.sanitizeHTML)throw Error("RichTextEditor must be passed a sanitizeHTML function as a prop");const r=b.useContext(p);r.sanitizeHTML=a.sanitizeHTML;const s=b.useRef(null),t=b.useRef(null),{isFocused:u,setFocused:v}=f(),w=b.useRef(q++),[x,y]=b.useState(()=>r.sanitizeHTML(a.initialHTML,"initialSetLastSavedHTML")),[z,A]=b.useState(!1);c&&(c.current={setHTML:k,resetEditor:function(){k("")},getHTML:l,focus:n}),b.useEffect(()=>(s.current.addEventListener("paste",d),()=>s.current.removeEventListener("paste",d)),[a.pasteFn]),b.useEffect(()=>(document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h))),b.useEffect(()=>{if(a.save&&a.unchangedInterval&&s.current&&u()){let b;const c=new MutationObserver(()=>{clearTimeout(b),b=setTimeout(i,a.unchangedInterval)});return c.observe(s.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{c.disconnect(),clearTimeout(b)}}},[a.unchangedInterval,a.save,s.current,u()]),b.useEffect(()=>{if(!1===u()){const a=setTimeout(()=>{r.fireBlur(),i()},100);return()=>{clearTimeout(a)}}},[u()]),b.useEffect(()=>{r.selectRangeFromBeforeBlur=function(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{usePreviousRange:!1};if(s.current&&document.activeElement!==s.current&&!s.current.contains(document.activeElement)){if(a.usePreviousRange&&t.current){const a=window.getSelection();a.removeAllRanges(),a.addRange(t.current)}else s.current.focus();v(!0),setTimeout(h)}},r.getRangeFromBeforeBlur=()=>t.current,r.isFocused=u,r.getContentEditableElement=()=>s.current}),b.useEffect(()=>{!z&&a.initialHTML&&(A(!0),k(a.initialHTML))},[z,k,r]),b.useEffect(()=>{if(a.placeholder){const a=document.createElement("style");return a.textContent=".bandicoot-id-".concat(w.current,":empty:before { content: attr(data-placeholder); ").concat(o()," }"),document.head.appendChild(a),()=>a.parentNode.removeChild(a)}},[a.placeholder,a.placeholderColor,w.current]);const B=a.style||{};return m.createElement("div",{contentEditable:!a.disabled,onBlur:()=>v(!1),onFocus:function(){v(!0);const a=window.getSelection();0<a.rangeCount&&(t.current=a.getRangeAt(0))},ref:s,className:a.className+" bandicoot-id-"+w.current,style:e({wordBreak:"break-word",wordWrap:"break-word",overflowWrap:"break-word"},B),"data-placeholder":a.placeholder})});r.defaultProps={className:"",initialHTML:"",save:()=>{},placeholder:"",pasteFn:a=>a};const s={isActive:!1,value:!1},t=()=>{},u=".jpg, .png, image/*",v={processImgElement:t,fileBlobToUrl:h,acceptImgTypes:u};let w=0;const x=()=>{},y={processAnchorElement:x};let z=0;const A=()=>{},B={processContentEditableFalseElement:A},C=()=>{},D={processSerializedElement:C,fontFamily:null};a.RichTextContainer=function(a){const c=b.useRef(Object.assign({},o)),d=c.current,e=b.useRef([]),f=b.useRef([]),g=b.useRef([]),h=b.useRef([]);return b.useEffect(()=>{const a=d.getContentEditableElement();a&&a.innerHTML&&d.fireNewHTML()},[d]),d.addSelectionChangedListener=a=>{e.current.push(a)},d.removeSelectionChangedListener=a=>{e.current=e.current.filter(b=>b!==a)},d.fireSelectionChanged=()=>{e.current.forEach(a=>a())},d.addBlurListener=a=>{f.current.push(a)},d.removeBlurListener=a=>{f.current=f.current.filter(b=>b!==a)},d.fireBlur=()=>{f.current.forEach(a=>a())},d.addNewHTMLListener=a=>{g.current.push(a)},d.removeNewHTMLListener=a=>{g.current=g.current.filter(b=>b!==a)},d.fireNewHTML=()=>{g.current.forEach(a=>a())},d.numSerializers=()=>h.current.length,d.addSerializer=a=>{h.current.push(a)},d.removeSerializer=a=>{h.current=h.current.filter(b=>b!==a)},d.serialize=a=>(h.current.forEach(b=>b(a)),a.innerHTML),m.createElement(p.Provider,{value:d},a.children)},a.RichTextContext=p,a.RichTextEditor=r,a.useContentEditableFalse=function(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>i(a)),!a.previousSibling&&a.parentElement===e.getContentEditableElement()){const b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===e.getContentEditableElement()){const b=document.createElement("span");a.insertAdjacentElement("afterend",b)}i(a),c(a)}let{processContentEditableFalseElement:c=A}=0<arguments.length&&arguments[0]!==void 0?arguments[0]:B;const{performCommandWithValue:d}=g("insertHTML"),e=b.useContext(p);return{insertContentEditableFalseElement(b){const c="rte-ce-false-temp-id-"+z++,f="<span id=\"".concat(c,"\">").concat(e.sanitizeHTML(b,"insertContentEditableFalseHTML"),"</span>");d(f);const g=document.getElementById(c);a(g)}}},a.useDocumentExecCommand=g,a.useDocumentQueryCommandState=function(a,c){function d(){const b=document.queryCommandValue(a),d=c?c===b:document.queryCommandState(a);(d!==f.isActive||b!==f.value)&&g({isActive:d,value:b})}function e(){g(s)}const[f,g]=b.useState(s),h=b.useContext(p);return b.useEffect(()=>(h.addSelectionChangedListener(d),()=>h.removeSelectionChangedListener(d)),[f,g]),b.useEffect(()=>(h.addBlurListener(e),()=>h.removeBlurListener(e)),[f,g]),{isActive:f.isActive,activeValue:f.value}},a.useElementDeletionDetection=function(a,c){const d=b.useContext(p);b.useEffect(()=>{if(a){function b(){a.isConnected||a._bandicoot_delete_callback_called||(a._bandicoot_delete_callback_called=!0,c(a))}return d.addSelectionChangedListener(b),()=>d.removeSelectionChangedListener(b)}},[a,c])},a.useFontSize=function(a){let{defaultFontSize:d="14px",fontSizes:c}=a;if(7<c.length)throw Error("Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)");const[e,f]=b.useState(d),[h,i]=b.useState(null),{performCommandWithValue:j}=g("fontSize"),k=b.useContext(p),l=function(){return b.useEffect(()=>{function a(){const a=window.getSelection();if((!h||a.anchorNode!==h.anchorNode||a.anchorOffset!==h.anchorOffset||a.focusNode!==h.focusNode||a.focusOffset!==h.focusOffset)&&(i({anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),0<a.rangeCount)){let b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);const c=window.getComputedStyle(b).fontSize,d=c;d!==e&&f(d)}}return k.addSelectionChangedListener(a),()=>k.removeSelectionChangedListener(a)},[e,f,h]),e}();return function(){b.useEffect(()=>{const a=c.reduce((a,b,c)=>"".concat(a," font[size=\"").concat(c+1,"\"] {font-size: ").concat(b,"}"),""),b=document.createElement("style");return b.textContent=a,document.head.appendChild(b),()=>document.head.removeChild(b)},[c]),b.useEffect(()=>{function a(a){const b=a.querySelectorAll("font");for(let d=0;d<b.length;d++){const a=b[d],e=+a.getAttribute("size");if(e>c.length)throw Error("Cannot find fontSize for integer size '".concat(e,"'"));const f=c[e-1];a.removeAttribute("size"),a.style.fontSize=f,a.dataset.integerSize=e}}return k.addSerializer(a),()=>k.removeSerializer(a)},[c]),b.useEffect(()=>{function a(){const a=k.getContentEditableElement().querySelectorAll("font");for(let b=0;b<a.length;b++){const d=a[b],e=d.style.fontSize,f=c.findIndex(a=>a===e)+1;0<f&&(d.style.fontSize="",d.setAttribute("size",f))}}return k.addNewHTMLListener(a),()=>k.removeNewHTMLListener(a)},[c])}(),{currentlySelectedFontSize:l,setSize(a){const b=c.findIndex(b=>b===a)+1;if(0>=b)throw Error("Cannot set font size since '".concat(a,"' was not passed in the fontSizes array"));f(a),j(b)}}},a.useFormatBlock=function(){const{performCommandWithValue:a}=g("formatBlock");return{formatBlock(b){b===document.queryCommandValue("formatBlock")?a("div"):a(b)}}},a.useImage=function(){function a(a){a.style.cursor="pointer",a.style.maxWidth="100%",d(a)}function c(a){a.querySelectorAll("img").forEach(a=>{l.current[a.src]&&(a.src=l.current[a.src])})}let{processImgElement:d=t,fileBlobToUrl:e=h,acceptImgTypes:f=u}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:v;const{performCommandWithValue:i}=g("insertImage"),j=b.useContext(p),k=b.useRef(null),l=m.useRef({});return function(){b.useEffect(()=>{function b(){const b=j.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return j.addNewHTMLListener(b),()=>j.removeNewHTMLListener(b)},[d])}(),function(){b.useEffect(()=>{k.current=document.createElement("input");const b=k.current;b.type="file",b.accept=f,b.multiple=!1,b.addEventListener("change",()=>{b.files&&0<b.files.length&&e(b.files[0],c=>{i(c);const d=document.querySelector("img[src=\"".concat(c,"\"]"));if(d.src&&d.src.startsWith("blob:")){const a=new FileReader;a.addEventListener("load",()=>{l.current[d.src]=a.result}),a.readAsDataURL(b.files[0])}a(d)})})},[e,d,f])}(),function(){b.useEffect(()=>(j.addSerializer(c),()=>j.removeSerializer(c)))}(),{chooseFile(a){k.current.click()},removeImage(a){const b=document.createRange();b.selectNode(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}},a.useLink=function(){function a(a,b){d.selectRangeFromBeforeBlur({usePreviousRange:!0});const e="rte-link-temp-id-".concat(w++);f("<a href=\"".concat(a,"\" id=\"").concat(e,"\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(b,"</a>"));const g=document.getElementById(e);g.removeAttribute("id"),c(g)}let{processAnchorElement:c=x}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:y;const d=b.useContext(p),{performCommand:e}=g("unlink"),{performCommandWithValue:f}=g("insertHTML");return function(){b.useEffect(()=>{function a(){const a=d.getContentEditableElement().querySelectorAll("a");a.forEach(c)}return d.addNewHTMLListener(a),()=>d.removeNewHTMLListener(a)},[c])}(),{getTextFromBeforeBlur:function(){const a=d.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){const b=document.createRange();b.selectNodeContents(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:function(){e(),(window.navigator.userAgent.includes("Edge/14")||window.navigator.userAgent.includes("Edge/15")||window.navigator.userAgent.includes("Edge/16")||window.navigator.userAgent.includes("Edge/17"))&&document.execCommand("removeFormat")},insertLink:a}},a.useTextAsImage=function(){let{processSerializedElement:a=C,fontFamily:c=null}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:D;const{performCommandWithValue:d}=g("insertImage"),e=b.useContext(p);return function(){b.useEffect(()=>{function a(){const a=e.getContentEditableElement().querySelectorAll("span[data-text-as-image]");for(let b=0;b<a.length;b++){const d=a[b],e=j(d.dataset.textAsImage,d.previousElementSibling||d.nextElementSibling||d.parentElement,c),f=document.createElement("img");f.src=e,k(f,d.dataset.textAsImage),d.parentNode.replaceChild(f,d)}}return e.addNewHTMLListener(a),()=>e.removeNewHTMLListener(a)},[])}(),function(){b.useEffect(()=>{function b(b){const c=b.querySelectorAll("img[data-text-as-image]");for(let d=0;d<c.length;d++){const b=c[d],e=document.createElement("span");e.dataset.textAsImage=b.dataset.textAsImage,a(e,e.dataset.textAsImage),b.parentNode.replaceChild(e,b)}}return e.addSerializer(b),()=>e.removeSerializer(b)},[])}(),{insertTextAsImage(a){e.selectRangeFromBeforeBlur({usePreviousRange:!0});const b=j(a,l(),c);d(b);const f=document.querySelector("img[src=\"".concat(b,"\"]"));k(f,a)}}},Object.defineProperty(a,"__esModule",{value:!0})});
(function(a,b){"object"==typeof exports&&"undefined"!=typeof module?b(exports,require("react")):"function"==typeof define&&define.amd?define(["exports","react"],b):(a=a||self,b(a.bandicoot={},a.React))})(this,function(a,b){'use strict';function c(a,b,c){return b in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function d(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function e(a){for(var b,e=1;e<arguments.length;e++)b=null==arguments[e]?{}:arguments[e],e%2?d(b,!0).forEach(function(d){c(a,d,b[d])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):d(b).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function f(){const a=b.useRef(null),[c,d]=b.useState(!1);return{isFocused:function(){return a.current},setFocused:function(b){a.current=b,d(!c)}}}function g(a){const c=b.useContext(p);return{performCommand(b){c.selectRangeFromBeforeBlur(),document.execCommand(a)},performCommandWithValue(b){c.selectRangeFromBeforeBlur();document.execCommand(a,null,b)}}}function h(a,b){b(URL.createObjectURL(a))}function i(a){const b=document.createRange();b.setStartAfter(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)}function j(a,b,d){const e=window.getComputedStyle(b),f=+e.fontSize.replace("px",""),g=+e.lineHeight.replace("px",""),h=d||e.fontFamily,i="bold ".concat(f,"px ").concat(h),j=document.createElement("div");j.style.font=i,j.style.position="absolute",j.style.visibility="hidden",j.style.whiteSpace="nowrap",j.textContent=a,document.body.appendChild(j);const k=document.createElement("canvas");k.width=j.clientWidth+1,k.height=g;const l=k.getContext("2d");return l.font=i,l.fillStyle="#00bf4b",l.textBaseline="bottom",l.fillText(a,0,g-3),document.body.removeChild(j),l.canvas.toDataURL()}function k(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{const c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);const f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function l(){let a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}var m="default"in b?b["default"]:b;const n=()=>{},o={addSelectionChangedListener:n,removeSelectionChangedListener:n,fireSelectionChanged:n,selectRangeFromBeforeBlur:n,getRangeBeforeBlur:n,addBlurListener:n,removeBlurListener:n,fireBlur:n,addNewHTMLListener:n,removeNewHTMLListener:n,fireNewHTML:n,isFocused:n,getContentEditableElement:n,numSerializers:()=>0,addSerializer:n,removeSerializer:n,serialize:n,sanitizeHTML:n},p=m.createContext(o);let q=0;const r=b.forwardRef((a,c)=>{function d(b){b.preventDefault(),b.stopPropagation();let c=r.sanitizeHTML((window.clipboardData||b.clipboardData).getData("text/html"),"pasteHTML"),d=a.pasteFn(c);!1!==d&&document.execCommand("insertHTML",null,d)}function g(){const a=document.createRange();a.selectNodeContents(s.current);const b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("removeFormat"),document.execCommand("delete")}function h(){if(u()){const a=window.getSelection();0<a.rangeCount&&(t.current=window.getSelection().getRangeAt(0)),r.fireSelectionChanged()}}function i(){const b=l();b!==x&&(y(b),a.save(b))}function j(){let a=s.current.innerHTML;if(0<r.numSerializers()){const b=new DOMParser().parseFromString(a,"text/html");a=r.serialize(b.body)}return a}function k(b,c){c?(s.current.innerHTML=r.sanitizeHTML(b,"setHTML"),a.autoFocus&&n()):(g(),s.current.innerHTML=r.sanitizeHTML(b,"setHTML"),n()),r.fireNewHTML()}function l(){return r.sanitizeHTML(j(),"getHTML")}function n(){s.current.focus(),v(!0)}function o(){return a.placeholderColor?"color: ".concat(a.placeholderColor,";"):window.chrome&&(window.chrome.webstore||window.chrome.runtime)?"color: rgb(117, 117, 117);":"opacity: 0.54;"}if("function"!=typeof a.sanitizeHTML)throw Error("RichTextEditor must be passed a sanitizeHTML function as a prop");const r=b.useContext(p);r.sanitizeHTML=a.sanitizeHTML;const s=b.useRef(null),t=b.useRef(null),{isFocused:u,setFocused:v}=f(),w=b.useRef(q++),[x,y]=b.useState(()=>r.sanitizeHTML(a.initialHTML,"initialSetLastSavedHTML")),[z,A]=b.useState(!1);c&&(c.current={setHTML:k,resetEditor:function(){k("")},getHTML:l,focus:n}),b.useEffect(()=>(s.current.addEventListener("paste",d),()=>s.current.removeEventListener("paste",d)),[a.pasteFn]),b.useEffect(()=>(document.addEventListener("selectionchange",h),()=>document.removeEventListener("selectionchange",h))),b.useEffect(()=>{if(a.save&&a.unchangedInterval&&s.current&&u()){let b;const c=new MutationObserver(()=>{clearTimeout(b),b=setTimeout(i,a.unchangedInterval)});return c.observe(s.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{c.disconnect(),clearTimeout(b)}}},[a.unchangedInterval,a.save,s.current,u()]),b.useEffect(()=>{if(!1===u()){const a=setTimeout(()=>{r.fireBlur(),i()},100);return()=>{clearTimeout(a)}}},[u()]),b.useEffect(()=>{r.selectRangeFromBeforeBlur=function(){let a=0<arguments.length&&arguments[0]!==void 0?arguments[0]:{usePreviousRange:!1};if(s.current&&document.activeElement!==s.current&&!s.current.contains(document.activeElement)){if(a.usePreviousRange&&t.current){const a=window.getSelection();a.removeAllRanges(),a.addRange(t.current)}else s.current.focus();v(!0),setTimeout(h)}},r.getRangeFromBeforeBlur=()=>t.current,r.isFocused=u,r.getContentEditableElement=()=>s.current}),b.useEffect(()=>{!z&&a.initialHTML&&(A(!0),k(a.initialHTML,!0))},[z,k,r]),b.useEffect(()=>{if(a.placeholder){const a=document.createElement("style");return a.textContent=".bandicoot-id-".concat(w.current,":empty:before { content: attr(data-placeholder); ").concat(o()," }"),document.head.appendChild(a),()=>a.parentNode.removeChild(a)}},[a.placeholder,a.placeholderColor,w.current]);const B=a.style||{};return m.createElement("div",{contentEditable:!a.disabled,onBlur:()=>v(!1),onFocus:function(){v(!0);const a=window.getSelection();0<a.rangeCount&&(t.current=a.getRangeAt(0))},ref:s,className:a.className+" bandicoot-id-"+w.current,style:e({wordBreak:"break-word",wordWrap:"break-word",overflowWrap:"break-word"},B),"data-placeholder":a.placeholder})});r.defaultProps={className:"",initialHTML:"",save:()=>{},placeholder:"",pasteFn:a=>a};const s={isActive:!1,value:!1},t=()=>{},u=".jpg, .png, image/*",v={processImgElement:t,fileBlobToUrl:h,acceptImgTypes:u};let w=0;const x=()=>{},y={processAnchorElement:x};let z=0;const A=()=>{},B={processContentEditableFalseElement:A},C=()=>{},D={processSerializedElement:C,fontFamily:null};a.RichTextContainer=function(a){const c=b.useRef(Object.assign({},o)),d=c.current,e=b.useRef([]),f=b.useRef([]),g=b.useRef([]),h=b.useRef([]);return b.useEffect(()=>{const a=d.getContentEditableElement();a&&a.innerHTML&&d.fireNewHTML()},[d]),d.addSelectionChangedListener=a=>{e.current.push(a)},d.removeSelectionChangedListener=a=>{e.current=e.current.filter(b=>b!==a)},d.fireSelectionChanged=()=>{e.current.forEach(a=>a())},d.addBlurListener=a=>{f.current.push(a)},d.removeBlurListener=a=>{f.current=f.current.filter(b=>b!==a)},d.fireBlur=()=>{f.current.forEach(a=>a())},d.addNewHTMLListener=a=>{g.current.push(a)},d.removeNewHTMLListener=a=>{g.current=g.current.filter(b=>b!==a)},d.fireNewHTML=()=>{g.current.forEach(a=>a())},d.numSerializers=()=>h.current.length,d.addSerializer=a=>{h.current.push(a)},d.removeSerializer=a=>{h.current=h.current.filter(b=>b!==a)},d.serialize=a=>(h.current.forEach(b=>b(a)),a.innerHTML),m.createElement(p.Provider,{value:d},a.children)},a.RichTextContext=p,a.RichTextEditor=r,a.useContentEditableFalse=function(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>i(a)),!a.previousSibling&&a.parentElement===e.getContentEditableElement()){const b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===e.getContentEditableElement()){const b=document.createElement("span");a.insertAdjacentElement("afterend",b)}i(a),c(a)}let{processContentEditableFalseElement:c=A}=0<arguments.length&&arguments[0]!==void 0?arguments[0]:B;const{performCommandWithValue:d}=g("insertHTML"),e=b.useContext(p);return{insertContentEditableFalseElement(b){const c="rte-ce-false-temp-id-"+z++,f="<span id=\"".concat(c,"\">").concat(e.sanitizeHTML(b,"insertContentEditableFalseHTML"),"</span>");d(f);const g=document.getElementById(c);a(g)}}},a.useDocumentExecCommand=g,a.useDocumentQueryCommandState=function(a,c){function d(){const b=document.queryCommandValue(a),d=c?c===b:document.queryCommandState(a);(d!==f.isActive||b!==f.value)&&g({isActive:d,value:b})}function e(){g(s)}const[f,g]=b.useState(s),h=b.useContext(p);return b.useEffect(()=>(h.addSelectionChangedListener(d),()=>h.removeSelectionChangedListener(d)),[f,g]),b.useEffect(()=>(h.addBlurListener(e),()=>h.removeBlurListener(e)),[f,g]),{isActive:f.isActive,activeValue:f.value}},a.useElementDeletionDetection=function(a,c){const d=b.useContext(p);b.useEffect(()=>{if(a){function b(){a.isConnected||a._bandicoot_delete_callback_called||(a._bandicoot_delete_callback_called=!0,c(a))}return d.addSelectionChangedListener(b),()=>d.removeSelectionChangedListener(b)}},[a,c])},a.useFontSize=function(a){let{defaultFontSize:d="14px",fontSizes:c}=a;if(7<c.length)throw Error("Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)");const[e,f]=b.useState(d),[h,i]=b.useState(null),{performCommandWithValue:j}=g("fontSize"),k=b.useContext(p),l=function(){return b.useEffect(()=>{function a(){const a=window.getSelection();if((!h||a.anchorNode!==h.anchorNode||a.anchorOffset!==h.anchorOffset||a.focusNode!==h.focusNode||a.focusOffset!==h.focusOffset)&&(i({anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}),0<a.rangeCount)){let b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);const c=window.getComputedStyle(b).fontSize,d=c;d!==e&&f(d)}}return k.addSelectionChangedListener(a),()=>k.removeSelectionChangedListener(a)},[e,f,h]),e}();return function(){b.useEffect(()=>{const a=c.reduce((a,b,c)=>"".concat(a," font[size=\"").concat(c+1,"\"] {font-size: ").concat(b,"}"),""),b=document.createElement("style");return b.textContent=a,document.head.appendChild(b),()=>document.head.removeChild(b)},[c]),b.useEffect(()=>{function a(a){const b=a.querySelectorAll("font");for(let d=0;d<b.length;d++){const a=b[d],e=+a.getAttribute("size");if(e>c.length)throw Error("Cannot find fontSize for integer size '".concat(e,"'"));const f=c[e-1];a.removeAttribute("size"),a.style.fontSize=f,a.dataset.integerSize=e}}return k.addSerializer(a),()=>k.removeSerializer(a)},[c]),b.useEffect(()=>{function a(){const a=k.getContentEditableElement().querySelectorAll("font");for(let b=0;b<a.length;b++){const d=a[b],e=d.style.fontSize,f=c.findIndex(a=>a===e)+1;0<f&&(d.style.fontSize="",d.setAttribute("size",f))}}return k.addNewHTMLListener(a),()=>k.removeNewHTMLListener(a)},[c])}(),{currentlySelectedFontSize:l,setSize(a){const b=c.findIndex(b=>b===a)+1;if(0>=b)throw Error("Cannot set font size since '".concat(a,"' was not passed in the fontSizes array"));f(a),j(b)}}},a.useFormatBlock=function(){const{performCommandWithValue:a}=g("formatBlock");return{formatBlock(b){b===document.queryCommandValue("formatBlock")?a("div"):a(b)}}},a.useImage=function(){function a(a){a.style.cursor="pointer",a.style.maxWidth="100%",d(a)}function c(a){a.querySelectorAll("img").forEach(a=>{l.current[a.src]&&(a.src=l.current[a.src])})}let{processImgElement:d=t,fileBlobToUrl:e=h,acceptImgTypes:f=u}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:v;const{performCommandWithValue:i}=g("insertImage"),j=b.useContext(p),k=b.useRef(null),l=m.useRef({});return function(){b.useEffect(()=>{function b(){const b=j.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return j.addNewHTMLListener(b),()=>j.removeNewHTMLListener(b)},[d])}(),function(){b.useEffect(()=>{k.current=document.createElement("input");const b=k.current;b.type="file",b.accept=f,b.multiple=!1,b.addEventListener("change",()=>{b.files&&0<b.files.length&&e(b.files[0],c=>{i(c);const d=document.querySelector("img[src=\"".concat(c,"\"]"));if(d.src&&d.src.startsWith("blob:")){const a=new FileReader;a.addEventListener("load",()=>{l.current[d.src]=a.result}),a.readAsDataURL(b.files[0])}a(d)})})},[e,d,f])}(),function(){b.useEffect(()=>(j.addSerializer(c),()=>j.removeSerializer(c)))}(),{chooseFile(a){k.current.click()},removeImage(a){const b=document.createRange();b.selectNode(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}},a.useLink=function(){function a(a,b){d.selectRangeFromBeforeBlur({usePreviousRange:!0});const e="rte-link-temp-id-".concat(w++);f("<a href=\"".concat(a,"\" id=\"").concat(e,"\" target=\"_blank\" rel=\"noopener noreferrer\">").concat(b,"</a>"));const g=document.getElementById(e);g.removeAttribute("id"),c(g)}let{processAnchorElement:c=x}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:y;const d=b.useContext(p),{performCommand:e}=g("unlink"),{performCommandWithValue:f}=g("insertHTML");return function(){b.useEffect(()=>{function a(){const a=d.getContentEditableElement().querySelectorAll("a");a.forEach(c)}return d.addNewHTMLListener(a),()=>d.removeNewHTMLListener(a)},[c])}(),{getTextFromBeforeBlur:function(){const a=d.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){const b=document.createRange();b.selectNodeContents(a);const c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:function(){e(),(window.navigator.userAgent.includes("Edge/14")||window.navigator.userAgent.includes("Edge/15")||window.navigator.userAgent.includes("Edge/16")||window.navigator.userAgent.includes("Edge/17"))&&document.execCommand("removeFormat")},insertLink:a}},a.useTextAsImage=function(){let{processSerializedElement:a=C,fontFamily:c=null}=0<arguments.length&&void 0!==arguments[0]?arguments[0]:D;const{performCommandWithValue:d}=g("insertImage"),e=b.useContext(p);return function(){b.useEffect(()=>{function a(){const a=e.getContentEditableElement().querySelectorAll("span[data-text-as-image]");for(let b=0;b<a.length;b++){const d=a[b],e=j(d.dataset.textAsImage,d.previousElementSibling||d.nextElementSibling||d.parentElement,c),f=document.createElement("img");f.src=e,k(f,d.dataset.textAsImage),d.parentNode.replaceChild(f,d)}}return e.addNewHTMLListener(a),()=>e.removeNewHTMLListener(a)},[])}(),function(){b.useEffect(()=>{function b(b){const c=b.querySelectorAll("img[data-text-as-image]");for(let d=0;d<c.length;d++){const b=c[d],e=document.createElement("span");e.dataset.textAsImage=b.dataset.textAsImage,a(e,e.dataset.textAsImage),b.parentNode.replaceChild(e,b)}}return e.addSerializer(b),()=>e.removeSerializer(b)},[])}(),{insertTextAsImage(a){e.selectRangeFromBeforeBlur({usePreviousRange:!0});const b=j(a,l(),c);d(b);const f=document.querySelector("img[src=\"".concat(b,"\"]"));k(f,a)}}},Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=bandicoot.umd.js.map
{
"name": "bandicoot",
"version": "3.0.1",
"version": "3.0.2",
"description": "React rich text editor",

@@ -34,18 +34,18 @@ "main": "dist/bandicoot.umd.js",

"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.3.4",
"@babel/preset-env": "^7.3.4",
"@babel/cli": "^7.6.0",
"@babel/core": "^7.6.0",
"@babel/preset-env": "^7.6.0",
"@babel/preset-react": "^7.0.0",
"browserslist-config-canopy": "^2.0.0",
"react": "^16.8.4",
"react-dom": "^16.8.4",
"rimraf": "^2.6.3",
"rollup": "^1.5.0",
"rollup-plugin-babel": "^4.3.2",
"rollup-plugin-babel-minify": "^7.0.0",
"rollup-plugin-node-resolve": "^4.0.1"
"browserslist-config-canopy": "^3.1.2",
"react": "^16.9.0",
"react-dom": "^16.9.0",
"rimraf": "^3.0.0",
"rollup": "^1.21.4",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-babel-minify": "^9.0.0",
"rollup-plugin-node-resolve": "^5.2.0"
},
"dependencies": {
"@types/react": "^16.8.23"
"@types/react": "^16.9.2"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc