You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
9 lines
5.7 KiB
9 lines
5.7 KiB
2 years ago
|
/*
|
||
|
YUI 3.17.2 (build 9c3c78e)
|
||
|
Copyright 2014 Yahoo! Inc. All rights reserved.
|
||
|
Licensed under the BSD License.
|
||
|
http://yuilibrary.com/license/
|
||
|
*/
|
||
|
|
||
|
YUI.add("content-editable",function(e,t){var n=e.Lang,r=e.Node,i="contentready",s="ready",o="p",u="blur",a="container",f="contentEditable",l="",c="focus",h="host",p="innerHTML",d="key",v="parentNode",m="paste",g="Text",y="use",b=function(){b.superclass.constructor.apply(this,arguments)};e.extend(b,e.Plugin.Base,{_rendered:null,_instance:null,initializer:function(){var e=this.get(h);e&&(e.frame=this),this._eventHandles=[],this.publish(s,{emitFacade:!0,defaultFn:this._defReadyFn})},destructor:function(){(new e.EventHandle(this._eventHandles)).detach(),this._container.removeAttribute(f)},_onDomEvent:function(e){var t;e.frameX=e.frameY=0,(e.pageX>0||e.pageY>0)&&e.type.substring(0,3)!==d&&(t=this._container.getXY(),e.frameX=t[0],e.frameY=t[1]),e.frameTarget=e.target,e.frameCurrentTarget=e.currentTarget,e.frameEvent=e,this.fire("dom:"+e.type,e)},_DOMPaste:function(e){var t=this.getInstance(),n=l,r=t.config.win;e._event.originalTarget&&(n=e._event.originalTarget),e._event.clipboardData&&(n=e._event.clipboardData.getData(g)),r.clipboardData&&(n=r.clipboardData.getData(g),n===l&&(r.clipboardData.setData(g,n)||(n=null))),e.frameTarget=e.target,e.frameCurrentTarget=e.currentTarget,e.frameEvent=e,n?e.clipboardData={data:n,getData:function(){return n}}:e.clipboardData=null,this.fire("dom:paste",e)},_defReadyFn:function(){var t=this.getInstance(),n=this.get(a);e.each(b.DOM_EVENTS,function(r,i){var s=e.bind(this._onDomEvent,this),o=e.UA.ie&&b.THROTTLE_TIME>0?e.throttle(s,b.THROTTLE_TIME):s;t.Node.DOM_EVENTS[i]||(t.Node.DOM_EVENTS[i]=1),r===1&&i!==c&&i!==u&&i!==m&&(i.substring(0,3)===d?this._eventHandles.push(n.on(i,o,n)):this._eventHandles.push(n.on(i,s,n)))},this),t.Node.DOM_EVENTS.paste=1,this._eventHandles.push(n.on(m,e.bind(this._DOMPaste,this),n),n.on(c,e.bind(this._onDomEvent,this),n),n.on(u,e.bind(this._onDomEvent,this),n)),t.__use=t.use,t.use=e.bind(this.use,this)},_onContentReady:function(t){if(!this._ready){this._ready=!0;var n=this.getInstance(),o=e.clone(this.get(y));this.fire(i),t&&(n.config.doc=r.getDOMNode(t.target)),o.push(e.bind(function(){n.EditorSelection&&(n.EditorSelection.DEFAULT_BLOCK_TAG=this.get("defaultblock"),n.EditorSelection.ROOT=this.get(a)),this.fire(s)},this)),n.use.apply(n,o)}},_getDefaultBlock:function(){return this._getHostValue("defaultblock")},_getDir:function(){return this._getHostValue("dir")},_getExtraCSS:function(){return this._getHostValue("extracss")},_getHTML:function(){var e,t;return this._ready&&(t=this.get(a),e=t.get(p)),e},_getHostValue:function(e){var t=this.get(h);if(t)return t.get(e)},_setHTML:function(t){if(this._ready){var n=this.get(a);n.set(p,t)}else this.once(i,e.bind(this._setHTML,this,t));return t},_setLinkedCSS:function(t){if(this._ready){var n=this.getInstance();n.Get.css(t)}else this.once(i,e.bind(this._setLinkedCSS,this,t));return t},_setDir:function(t){var n;return this._ready?(n=this.get(a),n.setAttribute("dir",t)):this.once(i,e.bind(this._setDir,this,t)),t},_setExtraCSS:function(t){if(this._ready){if(t){var n=this.getInstance(),s=n.one("head");this._extraCSSNode&&this._extraCSSNode.remove(),this._extraCSSNode=r.create("<style>"+t+"</style>"),s.append(this._extraCSSNode)}}else this.once(i,e.bind(this._setExtraCSS,this,t));return t},_setLang:function(t){var n;return this._ready?(n=this.get(a),n.setAttribute("lang",t)):this.once(i,e.bind(this._setLang,this,t)),t},_instanceLoaded:function(t){this._instance=t,this._onContentReady();var n=this._instance.config.doc;if(!e.UA.ie)try{n.execCommand("styleWithCSS",!1,!1),n.execCommand("insertbronreturn",!1,!1)}catch(r){}},_validateLinkedCSS:function(e){return n.isString(e)||n.isArray(e)},use:function(){var t=this.getInstance(),r=e.Array(arguments),i=!1;return n.isFunction(r[r.length-1])&&(i=r.pop()),i&&r.push(function(){i.apply(t,arguments)}),t.__use.apply(t,r)},delegate:function(e,t,n,r){var i=this.getInstance();return i?(r||(r=n,n=this.get(a)),i.delegate(e,t,n,r)):!1},getInstance:function(){return this._instance},render:function(t){var n,i,s;return this._rendered?this:(t&&this.set(a,t),container=this.get(a),container||(container=r
|