@procore/core-react
Version:
JSX implementations for core-css
2 lines • 14.7 kB
JavaScript
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("react"),require("prop-types"));else if("function"==typeof define&&define.amd)define(["react","prop-types"],t);else{var n="object"==typeof exports?t(require("react"),require("prop-types")):t(e.react,e["prop-types"]);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(window,function(e,t){return function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=136)}({0:function(t,n){t.exports=e},136:function(e,t,n){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},r=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var i=n(0),c=n(165),u=n(137),a=n(138),s=n(139),l=i.createContext({wrapped:!1});t.TextEditor=function(e){var t=e.initialValue,n=void 0===t?"":t,p=e.onChange,f=void 0===p?function(e){}:p,d=e.plugins,y=void 0===d?s.DEFAULT_PLUGINS:d,h=r(e,["initialValue","onChange","plugins"]),v=a.consumeInjectedScript(),m=v.isLoaded,b=(v.setLoaded,u(function(e,t){return f(t.getContent())},s.THROTTLE_DURATION)),g=i.createElement(c.Editor,o({init:o({},s.TINY_MCE_CONFIG,{external_plugins:s.generateExternalPlugins(y)}),initialValue:n,onChange:b,onKeyUp:b},h));return i.createElement(l.Consumer,null,function(e){return e.wrapped?m&&g:null})},t.TextEditorProvider=function(e){var t=e.children;return i.createElement(a.InjectedScriptProvider,{id:s.SCRIPT_ID,src:s.TINY_MCE_SOURCE+"/"+s.TINY_MCE_VERSION+"/tinymce.min.js"},i.createElement(l.Provider,{value:{wrapped:!0}},t))},t.TextEditor.displayName="TextEditor",t.default=t.TextEditor},137:function(e,t,n){(function(t){var n="Expected a function",o=NaN,r="[object Symbol]",i=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,u=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt,l="object"==typeof t&&t&&t.Object===Object&&t,p="object"==typeof self&&self&&self.Object===Object&&self,f=l||p||Function("return this")(),d=Object.prototype.toString,y=Math.max,h=Math.min,v=function(){return f.Date.now()};function m(e,t,o){var r,i,c,u,a,s,l=0,p=!1,f=!1,d=!0;if("function"!=typeof e)throw new TypeError(n);function m(t){var n=r,o=i;return r=i=void 0,l=t,u=e.apply(o,n)}function _(e){var n=e-s;return void 0===s||n>=t||n<0||f&&e-l>=c}function O(){var e=v();if(_(e))return j(e);a=setTimeout(O,function(e){var n=t-(e-s);return f?h(n,c-(e-l)):n}(e))}function j(e){return a=void 0,d&&r?m(e):(r=i=void 0,u)}function C(){var e=v(),n=_(e);if(r=arguments,i=this,s=e,n){if(void 0===a)return function(e){return l=e,a=setTimeout(O,t),p?m(e):u}(s);if(f)return a=setTimeout(O,t),m(s)}return void 0===a&&(a=setTimeout(O,t)),u}return t=g(t)||0,b(o)&&(p=!!o.leading,c=(f="maxWait"in o)?y(g(o.maxWait)||0,t):c,d="trailing"in o?!!o.trailing:d),C.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=s=i=a=void 0},C.flush=function(){return void 0===a?u:j(v())},C}function b(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function g(e){if("number"==typeof e)return e;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&d.call(e)==r}(e))return o;if(b(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=b(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(i,"");var n=u.test(e);return n||a.test(e)?s(e.slice(2),n?2:8):c.test(e)?o:+e}e.exports=function(e,t,o){var r=!0,i=!0;if("function"!=typeof e)throw new TypeError(n);return b(o)&&(r="leading"in o?!!o.leading:r,i="trailing"in o?!!o.trailing:i),m(e,t,{leading:r,maxWait:t,trailing:i})}}).call(this,n(87))},138:function(e,t,n){"use strict";var o=this&&this.__assign||function(){return(o=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},r=this&&this.__rest||function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&(n[o[r]]=e[o[r]])}return n};Object.defineProperty(t,"__esModule",{value:!0});var i=n(0);t.useInjectedScript=function(e){var t=e.id,n=e.src,o=i.useState(!1),r=o[0],c=o[1];return i.useEffect(function(){if(document.getElementById(t))c(!0);else{var e=document.createElement("script");e.type="text/javascript",e.async=!0,e.id=t,e.onload=function(){c(!0)},e.src=n,document.head&&document.head.appendChild(e)}},[t,n]),{isLoaded:r,setLoaded:c}},t.withInjectedScript=function(e){return function(n){return function(r){return i.createElement(n,o({},r,{injectedScript:t.useInjectedScript(o({},e,r.injectedScript))}))}}},t.InjectedScript=function(e){var n=e.children,o=void 0===n?null:n,i=r(e,["children"]),c=t.useInjectedScript(i);return"function"==typeof o?o(c):o};var c;t.InjectedScriptContext=i.createContext({isLoaded:!1,setLoaded:(c="setLoaded",function(){return console.warn("Could not call `"+c+"`, please wrap your component in a `<InjectedScriptProvider>`")})}),t.InjectedScriptProvider=function(e){var n=e.children,o=r(e,["children"]);return i.createElement(t.InjectedScriptContext.Provider,{value:t.useInjectedScript(o)},n)},t.consumeInjectedScript=function(){return i.useContext(t.InjectedScriptContext)}},139:function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.SCRIPT_ID="tiny-mce-core-source",t.THROTTLE_DURATION=300,t.TINY_MCE_SOURCE="https://s3.amazonaws.com/procore-core/tinymce",t.TINY_MCE_VERSION="4.7.13",t.DEFAULT_PLUGINS=["autolink","autoresize","lists","nonbreaking","paste","textcolor"],t.PLUGINS=["advlist","anchor","autolink","autoresize","autosave","bbcode","charmap","code","codesample","colorpicker","contextmenu","directionality","emoticons","fullpage","fullscreen","help","hr","image","imagetools","importcss","insertdatetime","legacyoutput","link","lists","media","nonbreaking","noneditable","pagebreak","paste","preview","print","save","searchreplace","spellchecker","tabfocus","table","template","textcolor","textpattern","toc","visualblocks","visualchars","wordcount"],t.TINY_MCE_CONFIG={autoresize_overflow_padding:12,autoresize_bottom_margin:0,browser_spellcheck:!0,convert_url:!1,content_css:t.TINY_MCE_SOURCE+"/"+t.TINY_MCE_VERSION+"/tinymce.min.css",extended_valid_elements:"table[class=mce-table|border:1px double #000|cellpadding: 3px|style=border-collapse: collapse; border-color: #000]",min_height:96,invalid_elements:"form,script",menubar:!1,nonbreaking_force_tab:!0,paste_preprocess:function(e,t){t.content=t.content.replace(/<pre>/gi,"<p>"),t.content=t.content.replace(/<\/pre>/gi,"</p>")},paste_remove_styles_if_webkit:!0,paste_retain_style_properties:"font-size,text-decoration",paste_word_valid_elements:"@[style],pre,-strong/b,-em/i,-span,-p,-ol,-ul,-li,-table,-tr,-td[colspan|rowspan],-th,-thead,-tfoot,-tbody,-a[href|name],sub,sup,strike,br,u",statusbar:!1,skin_url:t.TINY_MCE_SOURCE+"/"+t.TINY_MCE_VERSION+"/skins/lightgray",toolbar:"bold italic underline alignleft aligncenter alignright bullist numlist outdent indent cut paste pastetext fontsizeselect forecolor backcolor undo redo"},t.generateExternalPlugins=function(e){return Array.from(new Set(e.concat(t.DEFAULT_PLUGINS))).reduce(function(e,n){var o;return t.PLUGINS.includes(n)?Object.assign(e,((o={})[n]=function(e){return t.TINY_MCE_SOURCE+"/"+t.TINY_MCE_VERSION+"/plugins/"+e+"/plugin.min.js"}(n),o)):e},{})}},165:function(e,t,n){"use strict";n.r(t);var o,r=n(0),i=n(5),c=function(){return(c=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},u={onActivate:i.func,onAddUndo:i.func,onBeforeAddUndo:i.func,onBeforeExecCommand:i.func,onBeforeGetContent:i.func,onBeforeRenderUI:i.func,onBeforeSetContent:i.func,onBeforePaste:i.func,onBlur:i.func,onChange:i.func,onClearUndos:i.func,onClick:i.func,onContextMenu:i.func,onCopy:i.func,onCut:i.func,onDblclick:i.func,onDeactivate:i.func,onDirty:i.func,onDrag:i.func,onDragDrop:i.func,onDragEnd:i.func,onDragGesture:i.func,onDragOver:i.func,onDrop:i.func,onExecCommand:i.func,onFocus:i.func,onFocusIn:i.func,onFocusOut:i.func,onGetContent:i.func,onHide:i.func,onInit:i.func,onKeyDown:i.func,onKeyPress:i.func,onKeyUp:i.func,onLoadContent:i.func,onMouseDown:i.func,onMouseEnter:i.func,onMouseLeave:i.func,onMouseMove:i.func,onMouseOut:i.func,onMouseOver:i.func,onMouseUp:i.func,onNodeChange:i.func,onObjectResizeStart:i.func,onObjectResized:i.func,onObjectSelected:i.func,onPaste:i.func,onPostProcess:i.func,onPostRender:i.func,onPreProcess:i.func,onProgressState:i.func,onRedo:i.func,onRemove:i.func,onReset:i.func,onSaveContent:i.func,onSelectionChange:i.func,onSetAttrib:i.func,onSetContent:i.func,onShow:i.func,onSubmit:i.func,onUndo:i.func,onVisualAid:i.func},a=c({apiKey:i.string,id:i.string,inline:i.bool,init:i.object,initialValue:i.string,onEditorChange:i.func,value:i.string,tagName:i.string,cloudChannel:i.string,plugins:i.oneOfType([i.string,i.array]),toolbar:i.oneOfType([i.string,i.array]),disabled:i.bool,textareaName:i.string},u),s=function(e){return"function"==typeof e},l=0,p=function(e){var t=(new Date).getTime();return e+"_"+Math.floor(1e9*Math.random())+ ++l+String(t)},f=function(e){return null!==e&&"textarea"===e.tagName.toLowerCase()},d=function(e){return void 0===e||""===e?[]:Array.isArray(e)?e:e.split(" ")},y=function(e,t){return d(e).concat(d(t))},h=n(66),v=(o=function(e,t){return(o=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])})(e,t)},function(e,t){function n(){this.constructor=e}o(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}),m=function(){return(m=Object.assign||function(e){for(var t,n=1,o=arguments.length;n<o;n++)for(var r in t=arguments[n])Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r]);return e}).apply(this,arguments)},b={listeners:[],scriptId:p("tiny-script"),scriptLoaded:!1},g=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.element=null,t.initialise=function(){var e=m({},t.props.init,{target:t.element,readonly:t.props.disabled,inline:t.inline,plugins:y(t.props.init&&t.props.init.plugins,t.props.plugins),toolbar:t.props.toolbar||t.props.init&&t.props.init.toolbar,setup:function(e){t.editor=e,e.on("init",function(n){t.initEditor(n,e)}),t.props.init&&"function"==typeof t.props.init.setup&&t.props.init.setup(e)}});f(t.element)&&(t.element.style.visibility=""),Object(h.a)().init(e)},t}return v(t,e),t.prototype.componentWillMount=function(){this.id=this.id||this.props.id||p("tiny-react"),this.inline=this.props.inline?this.props.inline:this.props.init&&this.props.init.inline},t.prototype.componentDidMount=function(){if(null!==Object(h.a)())this.initialise();else if(this.element&&this.element.ownerDocument){var e=this.element.ownerDocument,t=this.props.cloudChannel,n=this.props.apiKey?this.props.apiKey:"";!function(e,t,n,o){e.scriptLoaded?o():(e.listeners.push(o),t.getElementById(e.scriptId)||function(e,t,n,o){var r=t.createElement("script");r.type="application/javascript",r.id=e,r.addEventListener("load",o),r.src=n,t.head&&t.head.appendChild(r)}(e.scriptId,t,n,function(){e.listeners.forEach(function(e){return e()}),e.scriptLoaded=!0}))}(b,e,"https://cloud.tinymce.com/"+t+"/tinymce.min.js?apiKey="+n,this.initialise)}},t.prototype.componentWillUnmount=function(){null!==Object(h.a)()&&Object(h.a)().remove(this.editor)},t.prototype.componentWillReceiveProps=function(e){this.editor&&this.editor.initialized&&(this.currentContent=this.currentContent||this.editor.getContent(),"string"==typeof e.value&&e.value!==this.props.value&&e.value!==this.currentContent&&this.editor.setContent(e.value),"boolean"==typeof e.disabled&&e.disabled!==this.props.disabled&&this.editor.setMode(e.disabled?"readonly":"design"))},t.prototype.render=function(){return this.inline?this.renderInline():this.renderIframe()},t.prototype.initEditor=function(e,t){var n=this,o="string"==typeof this.props.value?this.props.value:"string"==typeof this.props.initialValue?this.props.initialValue:"";t.setContent(o),s(this.props.onEditorChange)&&t.on("change keyup setcontent",function(e){n.currentContent=t.getContent(),s(n.props.onEditorChange)&&n.props.onEditorChange(n.currentContent)}),function(e,t,n){var o;Object.keys(e).filter((o=Object.keys(u),function(e){return-1!==o.indexOf(e)})).forEach(function(o){var r=e[o];s(r)&&("onInit"===o?r(n,t):t.on(o.substring(2),function(e){return r(e,t)}))})}(this.props,t,e)},t.prototype.renderInline=function(){var e=this,t=this.props.tagName,n=void 0===t?"div":t;return r.createElement(n,{ref:function(t){return e.element=t},id:this.id})},t.prototype.renderIframe=function(){var e=this;return r.createElement("textarea",{ref:function(t){return e.element=t},style:{visibility:"hidden"},id:this.id,name:this.props.textareaName})},t.propTypes=a,t.defaultProps={cloudChannel:"5"},t}(r.Component);n.d(t,"Editor",function(){return g})},5:function(e,n){e.exports=t},66:function(e,t,n){"use strict";(function(e){n.d(t,"a",function(){return r});var o=function(){return"undefined"!=typeof window?window:e},r=function(){var e=o();return e&&e.tinymce?e.tinymce:null}}).call(this,n(87))},87:function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n}})});
//# sourceMappingURL=TextEditor.js.map