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

bandicoot

Package Overview
Dependencies
Maintainers
2
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 2.0.3 to 2.0.4

2

dist/bandicoot.umd.js

@@ -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){return d(a)||e(a,b)||f()}function d(a){if(Array.isArray(a))return a}function e(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function g(a){var c=b.useContext(p);return{performCommand(){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){var b=document.createRange();b.setStartAfter(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b)}function j(a,b){var d=window.getComputedStyle(b),e=+d.fontSize.replace("px",""),f=+d.lineHeight.replace("px",""),g=d.fontFamily,h=`bold ${e}px ${g}`,i=document.createElement("div");i.style.font=h,i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="nowrap",i.textContent=a,document.body.appendChild(i);var j=document.createElement("canvas");j.width=i.clientWidth+1,j.height=f;var k=j.getContext("2d");return k.font=h,k.fillStyle="#00bf4b",k.textBaseline="bottom",k.fillText(a,0,f-3),document.body.removeChild(i),k.canvas.toDataURL()}function k(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{var c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);var f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function l(){var a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}var m="default"in b?b["default"]:b,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},p=m.createContext(o),q=b.forwardRef((a,d)=>{function e(){var a=document.createRange();a.selectNodeContents(i.current);var b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("delete")}function f(){if(k.current){var a=window.getSelection();0<a.rangeCount&&(j.current=window.getSelection().getRangeAt(0)),l.fireSelectionChanged()}}function g(){var b=h();b!==r&&(s(b),a.save(b))}function h(){var a=i.current.innerHTML;if(0<l.numSerializers()){var b=new DOMParser().parseFromString(a,"text/html");a=l.serialize(b.body)}return a}var i=b.useRef(null),j=b.useRef(null),k=b.useRef(!1),l=b.useContext(p),n=b.useRef(null),o=b.useState(a.initialHTML),q=c(o,2),r=q[0],s=q[1];return d&&(d.current={setHTML(a){e(),i.current.innerHTML=a,i.current.focus(),l.fireNewHTML()},resetEditor(){d.current.setHTML("")}}),b.useEffect(()=>(document.addEventListener("selectionchange",f),()=>document.removeEventListener("selectionchange",f))),b.useEffect(()=>{if(a.save&&a.unchangedInterval&&i.current&&k.current){setTimeout(g,a.unchangedInterval);var b=new MutationObserver(()=>{clearTimeout(n.current),n.current=setTimeout(g,a.unchangedInterval)});return b.observe(i.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{b.disconnect(),clearTimeout(n.current)}}},[a.unchangedInterval,a.save,i.current,k.current]),b.useEffect(()=>{l.selectRangeFromBeforeBlur=()=>{if(i.current&&document.activeElement!==i.current&&!i.current.contains(document.activeElement))if(j.current){var a=window.getSelection();a.removeAllRanges(),a.addRange(j.current)}else i.current.focus()},l.getRangeFromBeforeBlur=()=>j.current,l.isFocused=()=>k.current,l.getContentEditableElement=()=>i.current},[k.current]),b.useEffect(()=>{a.initialHTML&&(i.current.innerHTML=a.initialHTML,l.fireNewHTML())},[]),m.createElement("div",{contentEditable:!0,onBlur:function(){k.current=!1,setTimeout(()=>{k.current||(l.fireBlur(),g())},100)},onFocus:function(){k.current=!0;var a=window.getSelection();0<a.rangeCount&&(j.current=a.getRangeAt(0))},ref:i,className:a.className})});q.defaultProps={className:"",initialHTML:"",save:()=>{}};var r={isActive:!1,value:!1},s=()=>{},t={processImgElement:s,fileBlobToUrl:h},u=0,v=()=>{},w={processAnchorElement:v},x=0,y=()=>{},z={processContentEditableFalseElement:y},A=()=>{},B={processSerializedElement:A};a.RichTextEditor=q,a.RichTextContainer=function(a){var c=b.useRef(Object.assign({},o)),d=c.current,e=b.useRef([]),f=b.useRef([]),g=b.useRef([]),h=b.useRef([]);return 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.useDocumentExecCommand=g,a.useDocumentQueryCommandState=function(a){function d(){var b=document.queryCommandState(a),c=document.queryCommandValue(a);(b!==h.isActive||c!==h.value)&&i({isActive:b,value:c})}function e(){i(r)}var f=b.useState(r),g=c(f,2),h=g[0],i=g[1],j=b.useContext(p);return b.useEffect(()=>(j.addSelectionChangedListener(d),()=>j.removeSelectionChangedListener(d)),[h,i]),b.useEffect(()=>(j.addBlurListener(e),()=>j.removeBlurListener(e)),[h,i]),{isActive:h.isActive,activeValue:h.value}},a.useFontSize=function(a){var d=a.defaultFontSize,e=void 0===d?"14px":d,f=a.fontSizes;if(7<f.length)throw Error(`Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)`);var h=g("fontSize"),i=h.performCommandWithValue,j=b.useContext(p),k=function(){var a=b.useState(e),d=c(a,2),f=d[0],g=d[1];return b.useEffect(()=>{function a(){var a=window.getSelection(),b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);var c=window.getComputedStyle(b).fontSize,d=+c.slice(0,c.length-2);d!==f&&g(d)}return j.addSelectionChangedListener(a),()=>j.removeSelectionChangedListener(a)},[f,g]),f}();return function(){b.useEffect(()=>{var a=f.reduce((a,b,c)=>`${a} font[size="${c+1}"] {font-size: ${b}}`,""),b=document.createElement("style");return b.textContent=a,document.head.appendChild(b),()=>document.head.removeChild(b)},[f]),b.useEffect(()=>{function a(a){for(var b=a.querySelectorAll("font"),c=0;c<b.length;c++){var d=b[c],e=+d.getAttribute("size");if(e>f.length)throw Error(`Cannot find fontSize for integer size '${e}'`);var g=f[e-1];d.removeAttribute("size"),d.style.fontSize=g,d.dataset.integerSize=e}}return j.addSerializer(a),()=>j.removeSerializer(a)},[f]),b.useEffect(()=>{function a(){for(var a=j.getContentEditableElement().querySelectorAll("font"),b=function(b){var c=a[b],d=c.style.fontSize,e=f.findIndex(a=>a===d)+1;0<e&&(c.style.fontSize="",c.setAttribute("size",e))},c=0;c<a.length;c++)b(c)}return j.addNewHTMLListener(a),()=>j.removeNewHTMLListener(a)},[f])}(),{currentlySelectedFontSize:k,setSize(a){var b=f.findIndex(b=>b===a)+1;if(0>=b)throw Error(`Cannot set font size since '${a}' was not passed in the fontSizes array`);i(b)}}},a.useImage=function(){function a(a){a.style.cursor="pointer",e(a)}var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:t,d=c.processImgElement,e=void 0===d?s:d,f=c.fileBlobToUrl,i=void 0===f?h:f,j=g("insertImage"),k=j.performCommandWithValue,l=b.useContext(p),m=b.useRef(null);return function(){b.useEffect(()=>{function b(){var b=l.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return l.addNewHTMLListener(b),()=>l.removeNewHTMLListener(b)},[e])}(),function(){b.useEffect(()=>{m.current=document.createElement("input");var b=m.current;b.type="file",b.accept=".jpg, .png, image/*",b.multiple=!1,b.addEventListener("input",()=>{b.files&&0<b.files.length&&i(b.files[0],b=>{k(b);var c=document.querySelector(`img[src="${b}"]`);a(c)})})},[i,e])}(),{chooseFile(){m.current.click()},removeImage(a){var b=document.createRange();b.selectNode(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}},a.useLink=function(){function a(a,b){var c=`rte-link-temp-id-${u++}`;k(`<a href="${a}" id="${c}">${b}</a>`);var d=document.getElementById(c);d.removeAttribute("id"),e(d)}var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:w,d=c.processAnchorElement,e=void 0===d?v:d,f=b.useContext(p),h=g("unlink"),i=h.performCommand,j=g("insertHTML"),k=j.performCommandWithValue;return function(){b.useEffect(()=>{function a(){var a=f.getContentEditableElement().querySelectorAll("a");a.forEach(e)}return f.addNewHTMLListener(a),()=>f.removeNewHTMLListener(a)},[e])}(),{getTextFromBeforeBlur:function(){var a=f.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){var b=document.createRange();b.selectNodeContents(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:i,insertLink:a}},a.useContentEditableFalse=function(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>i(a)),!a.previousSibling&&a.parentElement===j.getContentEditableElement()){var b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===j.getContentEditableElement()){var c=document.createElement("span");a.insertAdjacentElement("afterend",c)}i(a),e(a)}var c=0<arguments.length&&arguments[0]!==void 0?arguments[0]:z,d=c.processContentEditableFalseElement,e=void 0===d?y:d,f=g("insertHTML"),h=f.performCommandWithValue,j=b.useContext(p);return{insertContentEditableFalseElement(b){var c="rte-ce-false-temp-id-"+x++;h(`<span id="${c}">${b}</span>`);var d=document.getElementById(c);a(d)}}},a.useTextAsImage=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:B,c=a.processSerializedElement,d=void 0===c?A:c,e=g("insertImage"),f=e.performCommandWithValue,h=b.useContext(p);return function(){b.useEffect(()=>{function a(){for(var a=h.getContentEditableElement().querySelectorAll("span[data-text-as-image]"),b=0;b<a.length;b++){var c=a[b],d=j(c.dataset.textAsImage,c.previousElementSibling||c.nextElementSibling||c.parentElement),e=document.createElement("img");e.src=d,k(e,c.dataset.textAsImage),c.parentNode.replaceChild(e,c)}}return h.addNewHTMLListener(a),()=>h.removeNewHTMLListener(a)},[])}(),function(){b.useEffect(()=>{function a(a){for(var b=a.querySelectorAll("img[data-text-as-image]"),c=0;c<b.length;c++){var e=b[c],f=document.createElement("span");f.dataset.textAsImage=e.dataset.textAsImage,d(f,f.dataset.textAsImage),e.parentNode.replaceChild(f,e)}}return h.addSerializer(a),()=>h.removeSerializer(a)},[])}(),{insertTextAsImage(a){h.selectRangeFromBeforeBlur();var b=j(a,l());f(b);var c=document.querySelector(`img[src="${b}"]`);k(c,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){return d(a)||e(a,b)||f()}function d(a){if(Array.isArray(a))return a}function e(a,b){var c=[],d=!0,e=!1,f=void 0;try{for(var g,h=a[Symbol.iterator]();!(d=(g=h.next()).done)&&(c.push(g.value),!(b&&c.length===b));d=!0);}catch(a){e=!0,f=a}finally{try{d||null==h["return"]||h["return"]()}finally{if(e)throw f}}return c}function f(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}function g(a){var c=b.useContext(p);return{performCommand(){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){var b=document.createRange();b.setStartAfter(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b)}function j(a,b){var d=window.getComputedStyle(b),e=+d.fontSize.replace("px",""),f=+d.lineHeight.replace("px",""),g=d.fontFamily,h=`bold ${e}px ${g}`,i=document.createElement("div");i.style.font=h,i.style.position="absolute",i.style.visibility="hidden",i.style.whiteSpace="nowrap",i.textContent=a,document.body.appendChild(i);var j=document.createElement("canvas");j.width=i.clientWidth+1,j.height=f;var k=j.getContext("2d");return k.font=h,k.fillStyle="#00bf4b",k.textBaseline="bottom",k.fillText(a,0,f-3),document.body.removeChild(i),k.canvas.toDataURL()}function k(a,b){a.style.verticalAlign="bottom",a.dataset.textAsImage=b,a.addEventListener("click",b=>{var c=a.getBoundingClientRect(),d=c.left+c.width/2,e=document.createRange();b.x<d?e.setStartBefore(a):e.setStartAfter(a);var f=window.getSelection();f.removeAllRanges(),f.addRange(e)})}function l(){var a=getSelection().getRangeAt(0).commonAncestorContainer;return 1===a.nodeType?a:a.parentElement}var m="default"in b?b["default"]:b,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},p=m.createContext(o),q=b.forwardRef((a,d)=>{function e(){var a=document.createRange();a.selectNodeContents(i.current);var b=window.getSelection();b.removeAllRanges(),b.addRange(a),document.execCommand("delete")}function f(){if(k.current){var a=window.getSelection();0<a.rangeCount&&(j.current=window.getSelection().getRangeAt(0)),l.fireSelectionChanged()}}function g(){var b=h();b!==r&&(s(b),a.save(b))}function h(){var a=i.current.innerHTML;if(0<l.numSerializers()){var b=new DOMParser().parseFromString(a,"text/html");a=l.serialize(b.body)}return a}var i=b.useRef(null),j=b.useRef(null),k=b.useRef(!1),l=b.useContext(p),n=b.useRef(null),o=b.useState(a.initialHTML),q=c(o,2),r=q[0],s=q[1];return d&&(d.current={setHTML(a){e(),i.current.innerHTML=a,i.current.focus(),l.fireNewHTML()},resetEditor(){d.current.setHTML("")}}),b.useEffect(()=>(document.addEventListener("selectionchange",f),()=>document.removeEventListener("selectionchange",f))),b.useEffect(()=>{if(a.save&&a.unchangedInterval&&i.current&&k.current){setTimeout(g,a.unchangedInterval);var b=new MutationObserver(()=>{clearTimeout(n.current),n.current=setTimeout(g,a.unchangedInterval)});return b.observe(i.current,{attributes:!0,childList:!0,subtree:!0,characterData:!0}),()=>{b.disconnect(),clearTimeout(n.current)}}},[a.unchangedInterval,a.save,i.current,k.current]),b.useEffect(()=>{l.selectRangeFromBeforeBlur=()=>{if(i.current&&document.activeElement!==i.current&&!i.current.contains(document.activeElement))if(j.current){var a=window.getSelection();a.removeAllRanges(),a.addRange(j.current)}else i.current.focus()},l.getRangeFromBeforeBlur=()=>j.current,l.isFocused=()=>k.current,l.getContentEditableElement=()=>i.current},[k.current]),b.useEffect(()=>{a.initialHTML&&(i.current.innerHTML=a.initialHTML,l.fireNewHTML())},[]),m.createElement("div",{contentEditable:!0,onBlur:function(){k.current=!1,setTimeout(()=>{k.current||(l.fireBlur(),g())},100)},onFocus:function(){k.current=!0;var a=window.getSelection();0<a.rangeCount&&(j.current=a.getRangeAt(0))},ref:i,className:a.className})});q.defaultProps={className:"",initialHTML:"",save:()=>{}};var r={isActive:!1,value:!1},s=()=>{},t={processImgElement:s,fileBlobToUrl:h},u=0,v=()=>{},w={processAnchorElement:v},x=0,y=()=>{},z={processContentEditableFalseElement:y},A=()=>{},B={processSerializedElement:A};a.RichTextEditor=q,a.RichTextContainer=function(a){var c=b.useRef(Object.assign({},o)),d=c.current,e=b.useRef([]),f=b.useRef([]),g=b.useRef([]),h=b.useRef([]);return 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.useDocumentExecCommand=g,a.useDocumentQueryCommandState=function(a){function d(){var b=document.queryCommandState(a),c=document.queryCommandValue(a);(b!==h.isActive||c!==h.value)&&i({isActive:b,value:c})}function e(){i(r)}var f=b.useState(r),g=c(f,2),h=g[0],i=g[1],j=b.useContext(p);return b.useEffect(()=>(j.addSelectionChangedListener(d),()=>j.removeSelectionChangedListener(d)),[h,i]),b.useEffect(()=>(j.addBlurListener(e),()=>j.removeBlurListener(e)),[h,i]),{isActive:h.isActive,activeValue:h.value}},a.useFontSize=function(a){var d=a.defaultFontSize,e=void 0===d?"14px":d,f=a.fontSizes;if(7<f.length)throw Error(`Browsers only support up to 7 font sizes with document.execCommand('fontSize', null, size)`);var h=g("fontSize"),i=h.performCommandWithValue,j=b.useContext(p),k=function(){var a=b.useState(e),d=c(a,2),f=d[0],g=d[1];return b.useEffect(()=>{function a(){var a=window.getSelection(),b=a.getRangeAt(0).startContainer;1!==b.nodeType&&(b=b.parentElement);var c=window.getComputedStyle(b).fontSize,d=c;d!==f&&g(d)}return j.addSelectionChangedListener(a),()=>j.removeSelectionChangedListener(a)},[f,g]),f}();return function(){b.useEffect(()=>{var a=f.reduce((a,b,c)=>`${a} font[size="${c+1}"] {font-size: ${b}}`,""),b=document.createElement("style");return b.textContent=a,document.head.appendChild(b),()=>document.head.removeChild(b)},[f]),b.useEffect(()=>{function a(a){for(var b=a.querySelectorAll("font"),c=0;c<b.length;c++){var d=b[c],e=+d.getAttribute("size");if(e>f.length)throw Error(`Cannot find fontSize for integer size '${e}'`);var g=f[e-1];d.removeAttribute("size"),d.style.fontSize=g,d.dataset.integerSize=e}}return j.addSerializer(a),()=>j.removeSerializer(a)},[f]),b.useEffect(()=>{function a(){for(var a=j.getContentEditableElement().querySelectorAll("font"),b=function(b){var c=a[b],d=c.style.fontSize,e=f.findIndex(a=>a===d)+1;0<e&&(c.style.fontSize="",c.setAttribute("size",e))},c=0;c<a.length;c++)b(c)}return j.addNewHTMLListener(a),()=>j.removeNewHTMLListener(a)},[f])}(),{currentlySelectedFontSize:k,setSize(a){var b=f.findIndex(b=>b===a)+1;if(0>=b)throw Error(`Cannot set font size since '${a}' was not passed in the fontSizes array`);i(b)}}},a.useImage=function(){function a(a){a.style.cursor="pointer",e(a)}var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:t,d=c.processImgElement,e=void 0===d?s:d,f=c.fileBlobToUrl,i=void 0===f?h:f,j=g("insertImage"),k=j.performCommandWithValue,l=b.useContext(p),m=b.useRef(null);return function(){b.useEffect(()=>{function b(){var b=l.getContentEditableElement().querySelectorAll("img:not([data-text-as-image])");b.forEach(a)}return l.addNewHTMLListener(b),()=>l.removeNewHTMLListener(b)},[e])}(),function(){b.useEffect(()=>{m.current=document.createElement("input");var b=m.current;b.type="file",b.accept=".jpg, .png, image/*",b.multiple=!1,b.addEventListener("input",()=>{b.files&&0<b.files.length&&i(b.files[0],b=>{k(b);var c=document.querySelector(`img[src="${b}"]`);a(c)})})},[i,e])}(),{chooseFile(){m.current.click()},removeImage(a){var b=document.createRange();b.selectNode(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b),document.execCommand("delete")}}},a.useLink=function(){function a(a,b){var c=`rte-link-temp-id-${u++}`;k(`<a href="${a}" id="${c}">${b}</a>`);var d=document.getElementById(c);d.removeAttribute("id"),e(d)}var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:w,d=c.processAnchorElement,e=void 0===d?v:d,f=b.useContext(p),h=g("unlink"),i=h.performCommand,j=g("insertHTML"),k=j.performCommandWithValue;return function(){b.useEffect(()=>{function a(){var a=f.getContentEditableElement().querySelectorAll("a");a.forEach(e)}return f.addNewHTMLListener(a),()=>f.removeNewHTMLListener(a)},[e])}(),{getTextFromBeforeBlur:function(){var a=f.getRangeFromBeforeBlur();return a?a.toString():null},selectEntireLink:function(a){var b=document.createRange();b.selectNodeContents(a);var c=window.getSelection();c.removeAllRanges(),c.addRange(b)},unlink:i,insertLink:a}},a.useContentEditableFalse=function(){function a(a){if(a.removeAttribute("id"),a.contentEditable=!1,a.addEventListener("click",()=>i(a)),!a.previousSibling&&a.parentElement===j.getContentEditableElement()){var b=document.createElement("span");a.parentElement.insertBefore(b,a)}if(!a.nextSibling&&a.parentElement===j.getContentEditableElement()){var c=document.createElement("span");a.insertAdjacentElement("afterend",c)}i(a),e(a)}var c=0<arguments.length&&arguments[0]!==void 0?arguments[0]:z,d=c.processContentEditableFalseElement,e=void 0===d?y:d,f=g("insertHTML"),h=f.performCommandWithValue,j=b.useContext(p);return{insertContentEditableFalseElement(b){var c="rte-ce-false-temp-id-"+x++;h(`<span id="${c}">${b}</span>`);var d=document.getElementById(c);a(d)}}},a.useTextAsImage=function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:B,c=a.processSerializedElement,d=void 0===c?A:c,e=g("insertImage"),f=e.performCommandWithValue,h=b.useContext(p);return function(){b.useEffect(()=>{function a(){for(var a=h.getContentEditableElement().querySelectorAll("span[data-text-as-image]"),b=0;b<a.length;b++){var c=a[b],d=j(c.dataset.textAsImage,c.previousElementSibling||c.nextElementSibling||c.parentElement),e=document.createElement("img");e.src=d,k(e,c.dataset.textAsImage),c.parentNode.replaceChild(e,c)}}return h.addNewHTMLListener(a),()=>h.removeNewHTMLListener(a)},[])}(),function(){b.useEffect(()=>{function a(a){for(var b=a.querySelectorAll("img[data-text-as-image]"),c=0;c<b.length;c++){var e=b[c],f=document.createElement("span");f.dataset.textAsImage=e.dataset.textAsImage,d(f,f.dataset.textAsImage),e.parentNode.replaceChild(f,e)}}return h.addSerializer(a),()=>h.removeSerializer(a)},[])}(),{insertTextAsImage(a){h.selectRangeFromBeforeBlur();var b=j(a,l());f(b);var c=document.querySelector(`img[src="${b}"]`);k(c,a)}}},Object.defineProperty(a,"__esModule",{value:!0})});
//# sourceMappingURL=bandicoot.umd.js.map
{
"name": "bandicoot",
"version": "2.0.3",
"version": "2.0.4",
"description": "React rich text editor",

@@ -5,0 +5,0 @@ "main": "dist/bandicoot.umd.js",

@@ -34,4 +34,7 @@ import resolve from 'rollup-plugin-node-resolve'

sourcemap: true,
globals: {
'react': 'React',
},
},
}),
]

@@ -41,3 +41,3 @@ import {useDocumentExecCommand} from './use-document-exec-command.hook.js'

const stringFontSize = window.getComputedStyle(selectionNode).fontSize
const newSize = Number(stringFontSize.slice(0, stringFontSize.length - 2))
const newSize = stringFontSize
if (newSize !== fontSize) {

@@ -44,0 +44,0 @@ setFontSize(newSize)

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