amis-rpc-design/dist/4699.7d223bb6.bundle.js

1 line
4.0 KiB
JavaScript
Raw Permalink Normal View History

2023-10-07 19:42:30 +08:00
"use strict";(self.webpackChunkamis_rpc_design=self.webpackChunkamis_rpc_design||[]).push([[4699],{4699:(t,e,i)=>{i.r(e),i.d(e,{default:()=>d});var n=i(14320),o=i(90375),s=i(80214),r=i.n(s),l=(i(65614),i(5814),i(21571),i(2929),i(26899),i(79787),i(62584),i(22133),i(80631),i(68220),i(30609),i(60833),i(35020),i(71630),i(86392),i(76067),i(72529),i(24496),i(77154),i(73397),i(64936),i(52034),i(29905),i(62106),i(45096),i(22733),i(16729),i(81838),i(26851),i(46117),function(t){function e(e){var i=t.call(this,e)||this;return i.listeningEvents=[],i.element=null,i.editor=null,i.config={immediateReactModelUpdate:!1,reactIgnoreAttrs:null},i.editorInitialized=!1,i.INNER_HTML_ATTR="innerHTML",i.oldModel=null,i}return(0,n.ZT)(e,t),e.prototype.componentDidMount=function(){this.createEditor()},e.prototype.componentWillUnmount=function(){this.destroyEditor()},e.prototype.componentDidUpdate=function(){JSON.stringify(this.oldModel)!=JSON.stringify(this.props.model)&&this.setContent()},e.prototype.clone=function(t){var e,i=this;if(!t)return t;if([Number,String,Boolean].forEach((function(i){t instanceof i&&(e=i(t))})),void 0===e)if("[object Array]"===Object.prototype.toString.call(t))e=[],t.forEach((function(t,n,o){e[n]=i.clone(t)}));else if("object"==typeof t)if(t.nodeType&&"function"==typeof t.cloneNode)e=t.cloneNode(!0);else if(t.prototype)e=t;else if(t instanceof Date)e=new Date(t);else for(var n in e={},t)e[n]=i.clone(t[n]);else e=t;return e},e.prototype.createEditor=function(){var t=this;this.editorInitialized||(this.config=this.clone(this.props.config||this.config),this.config=(0,n.pi)({},this.config),this.element=this.el,this.props.model&&(this.element.innerHTML=this.props.model),this.setContent(),this.registerEvent("initialized",this.config.events&&this.config.events.initialized),this.config.events||(this.config.events={}),this.config.events.initialized=function(){t.editorInitialized=!0,t.initListeners()},this.editor=new(r())(this.element,this.config))},e.prototype.setContent=function(){var t=this;(this.props.model||""==this.props.model)&&(this.oldModel=this.props.model,this.editorInitialized?this.setNormalTagContent():(this._initEvents||(this._initEvents=[]),this._initEvents.push((function(){return t.setNormalTagContent()}))))},e.prototype.setNormalTagContent=function(){var t=this;t.editor.html&&t.editor.html.set(t.props.model||""),t.editorInitialized&&t.editor.undo&&(t.editor.undo.reset(),t.editor.undo.saveStep())},e.prototype.destroyEditor=function(){this.element&&(this.editor.destroy&&this.editor.destroy(),this.listeningEvents.length=0,this.element=null,this.editorInitialized=!1,this._initEvents=[])},e.prototype.getEditor=function(){return this.element?this.editor:null},e.prototype.updateModel=function(){if(this.props.onModelChange){var t="",e=this.editor.html.get();"string"==typeof e&&(t=e),this.oldModel=t,this.props.onModelChange(t)}},e.prototype.initListeners=function(){var t=this;if(this.editor.events.on("contentChanged",(function(){t.updateModel()})),this.config.immediateReactModelUpdate&&this.editor.events.on("keyup",(function(){t.updateModel()})),this._initEvents)for(var e=0;e<this._initEvents.length;e++)this._initEvents[e].call(this.editor)},e.prototype.registerEvent=function(t,e){t&&e&&("initialized"==t?(this._initEvents||(this._initEvents=[]),this._initEvents.push(e)):(this.config.events||(this.config.events={}),this.config.events[t]=e))},e.prototype.render=function(){var t=this;return o.Z.createElement("textarea",{ref:function(e){return t.el=e}},this.props.children)},e}(o.Z.Component)),d=function(t){function e(e){var i=t.call(this,e)||this;return r().VIDEO_PROVIDERS=[{test_regex:/.*/,url_regex:"",url_text:"",html:'<span class="fr-video fr-dvb fr-draggable" contenteditable="false" draggable="true"><video class="fr-draggable" controls="" data-msg="ok" data-status="0" src="{url}" style="width: 600px;"></video></span>'}],i}return(0,n.ZT)(e,t),e.prototype.render=function(){return o.Z.createElement(l,{config:this.props.config,model:this.props.model,onModelChange:this.props.onModelChange})},e}(o.Z.Component)}}]);