vue-html5-editor.js 83 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520
  1. /**
  2. * Vue-html5-editor 1.1.1
  3. * https://github.com/PeakTai/vue-html5-editor
  4. * build at Thu Apr 20 2017 16:31:37 GMT+0800 (CST)
  5. */
  6. (function (global, factory) {
  7. typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  8. typeof define === 'function' && define.amd ? define(factory) :
  9. (global.VueHtml5Editor = factory());
  10. }(this, (function () { 'use strict';
  11. function __$styleInject(css, returnValue) {
  12. if (typeof document === 'undefined') {
  13. return returnValue;
  14. }
  15. css = css || '';
  16. var head = document.head || document.getElementsByTagName('head')[0];
  17. var style = document.createElement('style');
  18. style.type = 'text/css';
  19. if (style.styleSheet){
  20. style.styleSheet.cssText = css;
  21. } else {
  22. style.appendChild(document.createTextNode(css));
  23. }
  24. head.appendChild(style);
  25. return returnValue;
  26. }
  27. var polyfill = function () {
  28. // https://tc39.github.io/ecma262/#sec-array.prototype.includes
  29. if (!Array.prototype.includes) {
  30. Object.defineProperty(Array.prototype, 'includes', {
  31. value: function value(searchElement, fromIndex) {
  32. // 1. Let O be ? ToObject(this value).
  33. if (this == null) {
  34. throw new TypeError('"this" is null or not defined')
  35. }
  36. var o = Object(this);
  37. // 2. Let len be ? ToLength(? Get(O, "length")).
  38. var len = o.length >>> 0;
  39. // 3. If len is 0, return false.
  40. if (len === 0) {
  41. return false
  42. }
  43. // 4. Let n be ? ToInteger(fromIndex).
  44. // (If fromIndex is undefined, this step produces the value 0.)
  45. var n = fromIndex | 0;
  46. // 5. If n ≥ 0, then
  47. // a. Let k be n.
  48. // 6. Else n < 0,
  49. // a. Let k be len + n.
  50. // b. If k < 0, let k be 0.
  51. var k = Math.max(n >= 0 ? n : len - Math.abs(n), 0);
  52. // 7. Repeat, while k < len
  53. while (k < len) {
  54. // a. Let elementK be the result of ? Get(O, ! ToString(k)).
  55. // b. If SameValueZero(searchElement, elementK) is true, return true.
  56. // c. Increase k by 1.
  57. // NOTE: === provides the correct "SameValueZero" comparison needed here.
  58. if (o[k] === searchElement) {
  59. return true
  60. }
  61. k++;
  62. }
  63. // 8. Return false
  64. return false
  65. }
  66. });
  67. }
  68. // text.contains()
  69. if (!Text.prototype.contains) {
  70. Text.prototype.contains = function contains(node) {
  71. return this === node
  72. };
  73. }
  74. };
  75. var template = "<div> <button type=\"button\" @click=\"$parent.execCommand('justifyLeft')\"> {{$parent.locale[\"left justify\"]}} </button> <button type=\"button\" @click=\"$parent.execCommand('justifyCenter')\"> {{$parent.locale[\"center justify\"]}} </button> <button type=\"button\" @click=\"$parent.execCommand('justifyRight')\"> {{$parent.locale[\"right justify\"]}} </button> </div>";
  76. /**
  77. * Created by peak on 2017/2/10.
  78. */
  79. var dashboard = {
  80. template: template
  81. };
  82. /**
  83. * text align
  84. * Created by peak on 16/8/18.
  85. */
  86. var align = {
  87. name: 'align',
  88. icon: 'fa fa-align-center',
  89. i18n: 'align',
  90. dashboard: dashboard
  91. };
  92. var template$1 = "<div> <div> <label> <input type=\"radio\" value=\"foreColor\" v-model=\"command\">&nbsp; {{$parent.locale[\"fore color\"]}} </label> <label> <input type=\"radio\" value=\"backColor\" v-model=\"command\">&nbsp; {{$parent.locale[\"background color\"]}} </label> </div> <div> <div v-for=\"color in colors\" :style=\"{'background-color':color}\" class=\"color-card\" @click=\"changeColor(color)\"> </div> <div style=\"clear: both\"></div> </div> </div> ";
  93. __$styleInject(".vue-html5-editor .color-card{margin:2px;width:30px;height:30px;float:left;cursor:pointer}",undefined);
  94. /**
  95. * Created by peak on 2017/2/10.
  96. */
  97. var dashboard$1 = {
  98. template: template$1,
  99. data: function data(){
  100. return {
  101. // foreColor,backColor
  102. command: 'foreColor',
  103. colors: [
  104. '#000000', '#000033', '#000066', '#000099', '#003300', '#003333', '#003366',
  105. '#003399', '#006600', '#006633', '#009900', '#330000', '#330033', '#330066',
  106. '#333300', '#333366', '#660000', '#660033', '#663300', '#666600', '#666633',
  107. '#666666', '#666699', '#990000', '#990033', '#9900CC', '#996600', '#FFCC00',
  108. '#FFCCCC', '#FFCC99', '#FFFF00', '#FF9900', '#CCFFCC', '#CCFFFF', '#CCFF99'
  109. ]
  110. }
  111. },
  112. methods: {
  113. changeColor: function changeColor(color){
  114. this.$parent.execCommand(this.command, color);
  115. }
  116. }
  117. };
  118. /**
  119. * fore color and back color
  120. * Created by peak on 16/8/18.
  121. */
  122. var color = {
  123. name: 'color',
  124. icon: 'fa fa-paint-brush',
  125. i18n: 'color',
  126. dashboard: dashboard$1
  127. };
  128. /**
  129. * remove format of selection
  130. * Created by peak on 16/8/18.
  131. */
  132. var eraser = {
  133. name: 'eraser',
  134. icon: 'fa fa-eraser',
  135. i18n: 'eraser',
  136. handler: function handler(editor) {
  137. editor.execCommand('removeFormat');
  138. }
  139. };
  140. var template$2 = "<div class=\"dashboard-font\" style=\"line-height: 36px\"> <div> <label>{{$parent.locale[\"heading\"]}}:</label> <button v-for=\"h in 6\" type=\"button\" @click=\"setHeading(h)\">H{{h}}</button> </div> <div> <label> {{$parent.locale[\"font name\"]}}: </label> <button v-for=\"name in nameList\" type=\"button\" @click=\"setFontName(name)\">{{name}}</button> </div> <div> <label> {{$parent.locale[\"font size\"]}}: </label> <button v-for=\"size in fontSizeList\" type=\"button\" @click=\"setFontSize(size)\">{{size}}</button> </div> <div> <label> {{$parent.locale[\"line height\"]}}: </label> <button v-for=\"lh in lineHeightList\" type=\"button\" @click=\"setLineHeight(lh)\"> {{lh}} </button> </div> </div>";
  141. /**
  142. * Created by peak on 2017/2/14.
  143. */
  144. var Command = {
  145. JUSTIFY_LEFT: 'justifyLeft',
  146. JUSTIFY_CENTER: 'justifyCenter',
  147. JUSTIFY_RIGHT: 'justifyRight',
  148. FORE_COLOR: 'foreColor',
  149. BACK_COLOR: 'backColor',
  150. REMOVE_FORMAT: 'removeFormat',
  151. FONT_NAME: 'fontName',
  152. FONT_SIZE: 'fontSize',
  153. FORMAT_BLOCK: 'formatBlock',
  154. LINE_HEIGHT: 'lineHeight',
  155. INSERT_HORIZONTAL_RULE: 'insertHorizontalRule',
  156. INSERT_IMAGE: 'insertImage',
  157. CREATE_LINK: 'createLink',
  158. INSERT_ORDERED_LIST: 'insertOrderedList',
  159. INSERT_UNORDERED_LIST: 'insertUnorderedList',
  160. INSERT_HTML: 'insertHTML',
  161. BOLD: 'bold',
  162. ITALIC: 'italic',
  163. UNDERLINE: 'underline',
  164. STRIKE_THROUGH: 'strikeThrough',
  165. SUBSCRIPT: 'subscript',
  166. SUPERSCRIPT: 'superscript',
  167. UNDO: 'undo',
  168. UNLINK: 'unlink'
  169. };
  170. /**
  171. * Created by peak on 2017/2/10.
  172. */
  173. var dashboard$2 = {
  174. template: template$2,
  175. data: function data(){
  176. return {
  177. nameList: [
  178. 'Microsoft YaHei',
  179. 'Helvetica Neue',
  180. 'Helvetica',
  181. 'Arial',
  182. 'sans-serif',
  183. 'Verdana',
  184. 'Georgia',
  185. 'Times New Roman',
  186. 'Trebuchet MS',
  187. 'Microsoft JhengHei',
  188. 'Courier New',
  189. 'Impact',
  190. 'Comic Sans MS',
  191. 'Consolas'
  192. ],
  193. lineHeightList: [
  194. '1.0', '1.2', '1.5', '1.8', '2.0', '2.5', '3.0'
  195. ],
  196. fontSizeList: [
  197. '12px', '14px', '16px', '18px', '20px', '22px', '24px'
  198. ]
  199. }
  200. },
  201. methods: {
  202. setFontName: function setFontName(name){
  203. this.$parent.execCommand('fontName', name);
  204. },
  205. setFontSize: function setFontSize(size){
  206. this.$parent.execCommand('fontSize', size);
  207. },
  208. setHeading: function setHeading(heading){
  209. this.$parent.execCommand('formatBlock', ("h" + heading));
  210. },
  211. setLineHeight: function setLineHeight(lh){
  212. this.$parent.execCommand(Command.LINE_HEIGHT, lh);
  213. }
  214. },
  215. created: function created(){
  216. var config = this.$options.module.config;
  217. // font name
  218. if (!config) {
  219. return
  220. }
  221. if (Array.isArray(config.fontNames)) {
  222. this.nameList = config.fontNames;
  223. }
  224. }
  225. };
  226. /**
  227. * font name and font size
  228. * Created by peak on 16/8/18.
  229. */
  230. var font = {
  231. name: 'font',
  232. icon: 'fa fa-font',
  233. i18n: 'font',
  234. dashboard: dashboard$2
  235. };
  236. /**
  237. * toggle full screen mode
  238. * Created by peak on 16/8/18.
  239. */
  240. var fullScreen$1 = {
  241. name: 'full-screen',
  242. icon: 'fa fa-arrows-alt',
  243. i18n: 'full screen',
  244. handler: function handler(editor) {
  245. editor.toggleFullScreen();
  246. }
  247. };
  248. /**
  249. * hr
  250. * Created by peak on 16/8/20.
  251. */
  252. var hr = {
  253. name: 'hr',
  254. icon: 'fa fa-minus',
  255. i18n: 'hr',
  256. handler: function handler(editor) {
  257. editor.execCommand('insertHorizontalRule');
  258. }
  259. // init (editor) {
  260. //
  261. // },
  262. // destroyed(editor){
  263. //
  264. // },
  265. };
  266. var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
  267. function createCommonjsModule(fn, module) {
  268. return module = { exports: {} }, fn(module, module.exports), module.exports;
  269. }
  270. var lrz_all_bundle = createCommonjsModule(function (module, exports) {
  271. !function(e,t){if("object"==typeof exports&&"object"==typeof module){ module.exports=t(); }else if("function"==typeof undefined&&undefined.amd){ undefined([],t); }else{var n=t();for(var r in n){ ("object"==typeof exports?exports:e)[r]=n[r]; }}}(commonjsGlobal,function(){return function(e){function t(r){if(n[r]){ return n[r].exports; }var i=n[r]={exports:{},id:r,loaded:!1};return e[r].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){n(6),n(7),e.exports=n(8);},function(e,t,n){(function(t){!function(n){function r(e,t){return function(){e.apply(t,arguments);}}function i(e){if("object"!=typeof this){ throw new TypeError("Promises must be constructed via new"); }if("function"!=typeof e){ throw new TypeError("not a function"); }this._state=null,this._value=null,this._deferreds=[],l(e,r(a,this),r(s,this));}function o(e){var t=this;return null===this._state?void this._deferreds.push(e):void f(function(){var n=t._state?e.onFulfilled:e.onRejected;if(null===n){ return void(t._state?e.resolve:e.reject)(t._value); }var r;try{r=n(t._value);}catch(i){return void e.reject(i)}e.resolve(r);})}function a(e){try{if(e===this){ throw new TypeError("A promise cannot be resolved with itself."); }if(e&&("object"==typeof e||"function"==typeof e)){var t=e.then;if("function"==typeof t){ return void l(r(t,e),r(a,this),r(s,this)) }}this._state=!0,this._value=e,u.call(this);}catch(n){s.call(this,n);}}function s(e){this._state=!1,this._value=e,u.call(this);}function u(){
  272. var this$1 = this;
  273. for(var e=0,t=this._deferreds.length;t>e;e++){ o.call(this$1,this$1._deferreds[e]); }this._deferreds=null;}function c(e,t,n,r){this.onFulfilled="function"==typeof e?e:null,this.onRejected="function"==typeof t?t:null,this.resolve=n,this.reject=r;}function l(e,t,n){var r=!1;try{e(function(e){r||(r=!0,t(e));},function(e){r||(r=!0,n(e));});}catch(i){if(r){ return; }r=!0,n(i);}}var f="function"==typeof t&&t||function(e){setTimeout(e,1);},d=Array.isArray||function(e){return"[object Array]"===Object.prototype.toString.call(e)};i.prototype["catch"]=function(e){return this.then(null,e)},i.prototype.then=function(e,t){var n=this;return new i(function(r,i){o.call(n,new c(e,t,r,i));})},i.all=function(){var e=Array.prototype.slice.call(1===arguments.length&&d(arguments[0])?arguments[0]:arguments);return new i(function(t,n){function r(o,a){try{if(a&&("object"==typeof a||"function"==typeof a)){var s=a.then;if("function"==typeof s){ return void s.call(a,function(e){r(o,e);},n) }}e[o]=a,0===--i&&t(e);}catch(u){n(u);}}if(0===e.length){ return t([]); }for(var i=e.length,o=0;o<e.length;o++){ r(o,e[o]); }})},i.resolve=function(e){return e&&"object"==typeof e&&e.constructor===i?e:new i(function(t){t(e);})},i.reject=function(e){return new i(function(t,n){n(e);})},i.race=function(e){return new i(function(t,n){for(var r=0,i=e.length;i>r;r++){ e[r].then(t,n); }})},i._setImmediateFn=function(e){f=e;},i.prototype.always=function(e){var t=this.constructor;return this.then(function(n){return t.resolve(e()).then(function(){return n})},function(n){return t.resolve(e()).then(function(){throw n})})},"undefined"!=typeof e&&e.exports?e.exports=i:n.Promise||(n.Promise=i);}(this);}).call(t,n(2).setImmediate);},function(e,t,n){(function(e,r){function i(e,t){this._id=e,this._clearFn=t;}var o=n(3).nextTick,a=Function.prototype.apply,s=Array.prototype.slice,u={},c=0;t.setTimeout=function(){return new i(a.call(setTimeout,window,arguments),clearTimeout)},t.setInterval=function(){return new i(a.call(setInterval,window,arguments),clearInterval)},t.clearTimeout=t.clearInterval=function(e){e.close();},i.prototype.unref=i.prototype.ref=function(){},i.prototype.close=function(){this._clearFn.call(window,this._id);},t.enroll=function(e,t){clearTimeout(e._idleTimeoutId),e._idleTimeout=t;},t.unenroll=function(e){clearTimeout(e._idleTimeoutId),e._idleTimeout=-1;},t._unrefActive=t.active=function(e){clearTimeout(e._idleTimeoutId);var t=e._idleTimeout;t>=0&&(e._idleTimeoutId=setTimeout(function(){e._onTimeout&&e._onTimeout();},t));},t.setImmediate="function"==typeof e?e:function(e){var n=c++,r=arguments.length<2?!1:s.call(arguments,1);return u[n]=!0,o(function(){u[n]&&(r?e.apply(null,r):e.call(null),t.clearImmediate(n));}),n},t.clearImmediate="function"==typeof r?r:function(e){delete u[e];};}).call(t,n(2).setImmediate,n(2).clearImmediate);},function(e,t){function n(){c=!1,a.length?u=a.concat(u):l=-1,u.length&&r();}function r(){if(!c){var e=setTimeout(n);c=!0;for(var t=u.length;t;){for(a=u,u=[];++l<t;){ a&&a[l].run(); }l=-1,t=u.length;}a=null,c=!1,clearTimeout(e);}}function i(e,t){this.fun=e,this.array=t;}function o(){}var a,s=e.exports={},u=[],c=!1,l=-1;s.nextTick=function(e){
  274. var arguments$1 = arguments;
  275. var t=new Array(arguments.length-1);if(arguments.length>1){ for(var n=1;n<arguments.length;n++){ t[n-1]=arguments$1[n]; } }u.push(new i(e,t)),1!==u.length||c||setTimeout(r,0);},i.prototype.run=function(){this.fun.apply(null,this.array);},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=o,s.addListener=o,s.once=o,s.off=o,s.removeListener=o,s.removeAllListeners=o,s.emit=o,s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0};},function(e,t){function n(){var e=~navigator.userAgent.indexOf("Android")&&~navigator.vendor.indexOf("Google")&&!~navigator.userAgent.indexOf("Chrome");return e&&navigator.userAgent.match(/AppleWebKit\/(\d+)/).pop()<=534||/MQQBrowser/g.test(navigator.userAgent)}var r=function(){try{return new Blob,!0}catch(e){return!1}}()?window.Blob:function(e,t){var n=new(window.BlobBuilder||window.WebKitBlobBuilder||window.MSBlobBuilder||window.MozBlobBuilder);return e.forEach(function(e){n.append(e);}),n.getBlob(t?t.type:void 0)},i=function(){function e(){var e=this,n=[],i=Array(21).join("-")+(+new Date*(1e16*Math.random())).toString(36),o=XMLHttpRequest.prototype.send;this.getParts=function(){return n.toString()},this.append=function(e,t,r){n.push("--"+i+'\r\nContent-Disposition: form-data; name="'+e+'"'),t instanceof Blob?(n.push('; filename="'+(r||"blob")+'"\r\nContent-Type: '+t.type+"\r\n\r\n"),n.push(t)):n.push("\r\n\r\n"+t),n.push("\r\n");},t++,XMLHttpRequest.prototype.send=function(a){var s,u,c=this;a===e?(n.push("--"+i+"--\r\n"),u=new r(n),s=new FileReader,s.onload=function(){o.call(c,s.result);},s.onerror=function(e){throw e},s.readAsArrayBuffer(u),this.setRequestHeader("Content-Type","multipart/form-data; boundary="+i),t--,0==t&&(XMLHttpRequest.prototype.send=o)):o.call(this,a);};}var t=0;return e.prototype=Object.create(FormData.prototype),e}();e.exports={Blob:r,FormData:n()?i:FormData};},function(e,t,n){var r,i;(function(){function n(e){return!!e.exifdata}function o(e,t){t=t||e.match(/^data\:([^\;]+)\;base64,/im)[1]||"",e=e.replace(/^data\:([^\;]+)\;base64,/gim,"");for(var n=atob(e),r=n.length,i=new ArrayBuffer(r),o=new Uint8Array(i),a=0;r>a;a++){ o[a]=n.charCodeAt(a); }return i}function a(e,t){var n=new XMLHttpRequest;n.open("GET",e,!0),n.responseType="blob",n.onload=function(e){(200==this.status||0===this.status)&&t(this.response);},n.send();}function s(e,t){function n(n){var r=u(n),i=c(n);e.exifdata=r||{},e.iptcdata=i||{},t&&t.call(e);}if(e.src){ if(/^data\:/i.test(e.src)){var r=o(e.src);n(r);}else if(/^blob\:/i.test(e.src)){var i=new FileReader;i.onload=function(e){n(e.target.result);},a(e.src,function(e){i.readAsArrayBuffer(e);});}else{var s=new XMLHttpRequest;s.onload=function(){200==this.status||0===this.status?n(s.response):t(new Error("Could not load image")),s=null;},s.open("GET",e.src,!0),s.responseType="arraybuffer",s.send(null);} }else if(window.FileReader&&(e instanceof window.Blob||e instanceof window.File)){var i=new FileReader;i.onload=function(e){p&&console.log("Got file of length "+e.target.result.byteLength),n(e.target.result);},i.readAsArrayBuffer(e);}}function u(e){var t=new DataView(e);if(p&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1)){ return p&&console.log("Not a valid JPEG"),!1; }for(var n,r=2,i=e.byteLength;i>r;){if(255!=t.getUint8(r)){ return p&&console.log("Not a valid marker at offset "+r+", found: "+t.getUint8(r)),!1; }if(n=t.getUint8(r+1),p&&console.log(n),225==n){ return p&&console.log("Found 0xFFE1 marker"),g(t,r+4,t.getUint16(r+2)-2); }r+=2+t.getUint16(r+2);}}function c(e){var t=new DataView(e);if(p&&console.log("Got file of length "+e.byteLength),255!=t.getUint8(0)||216!=t.getUint8(1)){ return p&&console.log("Not a valid JPEG"),!1; }for(var n=2,r=e.byteLength,i=function(e,t){return 56===e.getUint8(t)&&66===e.getUint8(t+1)&&73===e.getUint8(t+2)&&77===e.getUint8(t+3)&&4===e.getUint8(t+4)&&4===e.getUint8(t+5)};r>n;){if(i(t,n)){var o=t.getUint8(n+7);o%2!==0&&(o+=1),0===o&&(o=4);var a=n+8+o,s=t.getUint16(n+6+o);return l(e,a,s)}n++;}}function l(e,t,n){for(var r,i,o,a,s,u=new DataView(e),c={},l=t;t+n>l;){ 28===u.getUint8(l)&&2===u.getUint8(l+1)&&(a=u.getUint8(l+2),a in S&&(o=u.getInt16(l+3),s=o+5,i=S[a],r=h(u,l+5,o),c.hasOwnProperty(i)?c[i]instanceof Array?c[i].push(r):c[i]=[c[i],r]:c[i]=r)),l++; }return c}function f(e,t,n,r,i){var o,a,s,u=e.getUint16(n,!i),c={};for(s=0;u>s;s++){ o=n+12*s+2,a=r[e.getUint16(o,!i)],!a&&p&&console.log("Unknown tag: "+e.getUint16(o,!i)),c[a]=d(e,o,t,n,i); }return c}function d(e,t,n,r,i){var o,a,s,u,c,l,f=e.getUint16(t+2,!i),d=e.getUint32(t+4,!i),g=e.getUint32(t+8,!i)+n;switch(f){case 1:case 7:if(1==d){ return e.getUint8(t+8,!i); }for(o=d>4?g:t+8,a=[],u=0;d>u;u++){ a[u]=e.getUint8(o+u); }return a;case 2:return o=d>4?g:t+8,h(e,o,d-1);case 3:if(1==d){ return e.getUint16(t+8,!i); }for(o=d>2?g:t+8,a=[],u=0;d>u;u++){ a[u]=e.getUint16(o+2*u,!i); }return a;case 4:if(1==d){ return e.getUint32(t+8,!i); }for(a=[],u=0;d>u;u++){ a[u]=e.getUint32(g+4*u,!i); }return a;case 5:if(1==d){ return c=e.getUint32(g,!i),l=e.getUint32(g+4,!i),s=new Number(c/l),s.numerator=c,s.denominator=l,s; }for(a=[],u=0;d>u;u++){ c=e.getUint32(g+8*u,!i),l=e.getUint32(g+4+8*u,!i),a[u]=new Number(c/l),a[u].numerator=c,a[u].denominator=l; }return a;case 9:if(1==d){ return e.getInt32(t+8,!i); }for(a=[],u=0;d>u;u++){ a[u]=e.getInt32(g+4*u,!i); }return a;case 10:if(1==d){ return e.getInt32(g,!i)/e.getInt32(g+4,!i); }for(a=[],u=0;d>u;u++){ a[u]=e.getInt32(g+8*u,!i)/e.getInt32(g+4+8*u,!i); }return a}}function h(e,t,n){var r,i="";for(r=t;t+n>r;r++){ i+=String.fromCharCode(e.getUint8(r)); }return i}function g(e,t){if("Exif"!=h(e,t,4)){ return p&&console.log("Not valid EXIF data! "+h(e,t,4)),!1; }var n,r,i,o,a,s=t+6;if(18761==e.getUint16(s)){ n=!1; }else{if(19789!=e.getUint16(s)){ return p&&console.log("Not valid TIFF data! (no 0x4949 or 0x4D4D)"),!1; }n=!0;}if(42!=e.getUint16(s+2,!n)){ return p&&console.log("Not valid TIFF data! (no 0x002A)"),!1; }var u=e.getUint32(s+4,!n);if(8>u){ return p&&console.log("Not valid TIFF data! (First offset less than 8)",e.getUint32(s+4,!n)),!1; }if(r=f(e,s,s+u,v,n),r.ExifIFDPointer){o=f(e,s,s+r.ExifIFDPointer,w,n);for(i in o){switch(i){case"LightSource":case"Flash":case"MeteringMode":case"ExposureProgram":case"SensingMethod":case"SceneCaptureType":case"SceneType":case"CustomRendered":case"WhiteBalance":case"GainControl":case"Contrast":case"Saturation":case"Sharpness":case"SubjectDistanceRange":case"FileSource":o[i]=b[i][o[i]];break;case"ExifVersion":case"FlashpixVersion":o[i]=String.fromCharCode(o[i][0],o[i][1],o[i][2],o[i][3]);break;case"ComponentsConfiguration":o[i]=b.Components[o[i][0]]+b.Components[o[i][1]]+b.Components[o[i][2]]+b.Components[o[i][3]];}r[i]=o[i];}}if(r.GPSInfoIFDPointer){a=f(e,s,s+r.GPSInfoIFDPointer,y,n);for(i in a){switch(i){case"GPSVersionID":a[i]=a[i][0]+"."+a[i][1]+"."+a[i][2]+"."+a[i][3];}r[i]=a[i];}}return r}var p=!1,m=function(e){return e instanceof m?e:this instanceof m?void(this.EXIFwrapped=e):new m(e)};"undefined"!=typeof e&&e.exports&&(t=e.exports=m),t.EXIF=m;var w=m.Tags={36864:"ExifVersion",40960:"FlashpixVersion",40961:"ColorSpace",40962:"PixelXDimension",40963:"PixelYDimension",37121:"ComponentsConfiguration",37122:"CompressedBitsPerPixel",37500:"MakerNote",37510:"UserComment",40964:"RelatedSoundFile",36867:"DateTimeOriginal",36868:"DateTimeDigitized",37520:"SubsecTime",37521:"SubsecTimeOriginal",37522:"SubsecTimeDigitized",33434:"ExposureTime",33437:"FNumber",34850:"ExposureProgram",34852:"SpectralSensitivity",34855:"ISOSpeedRatings",34856:"OECF",37377:"ShutterSpeedValue",37378:"ApertureValue",37379:"BrightnessValue",37380:"ExposureBias",37381:"MaxApertureValue",37382:"SubjectDistance",37383:"MeteringMode",37384:"LightSource",37385:"Flash",37396:"SubjectArea",37386:"FocalLength",41483:"FlashEnergy",41484:"SpatialFrequencyResponse",41486:"FocalPlaneXResolution",41487:"FocalPlaneYResolution",41488:"FocalPlaneResolutionUnit",41492:"SubjectLocation",41493:"ExposureIndex",41495:"SensingMethod",41728:"FileSource",41729:"SceneType",41730:"CFAPattern",41985:"CustomRendered",41986:"ExposureMode",41987:"WhiteBalance",41988:"DigitalZoomRation",41989:"FocalLengthIn35mmFilm",41990:"SceneCaptureType",41991:"GainControl",41992:"Contrast",41993:"Saturation",41994:"Sharpness",41995:"DeviceSettingDescription",41996:"SubjectDistanceRange",40965:"InteroperabilityIFDPointer",42016:"ImageUniqueID"},v=m.TiffTags={256:"ImageWidth",257:"ImageHeight",34665:"ExifIFDPointer",34853:"GPSInfoIFDPointer",40965:"InteroperabilityIFDPointer",258:"BitsPerSample",259:"Compression",262:"PhotometricInterpretation",274:"Orientation",277:"SamplesPerPixel",284:"PlanarConfiguration",530:"YCbCrSubSampling",531:"YCbCrPositioning",282:"XResolution",283:"YResolution",296:"ResolutionUnit",273:"StripOffsets",278:"RowsPerStrip",279:"StripByteCounts",513:"JPEGInterchangeFormat",514:"JPEGInterchangeFormatLength",301:"TransferFunction",318:"WhitePoint",319:"PrimaryChromaticities",529:"YCbCrCoefficients",532:"ReferenceBlackWhite",306:"DateTime",270:"ImageDescription",271:"Make",272:"Model",305:"Software",315:"Artist",33432:"Copyright"},y=m.GPSTags={0:"GPSVersionID",1:"GPSLatitudeRef",2:"GPSLatitude",3:"GPSLongitudeRef",4:"GPSLongitude",5:"GPSAltitudeRef",6:"GPSAltitude",7:"GPSTimeStamp",8:"GPSSatellites",9:"GPSStatus",10:"GPSMeasureMode",11:"GPSDOP",12:"GPSSpeedRef",13:"GPSSpeed",14:"GPSTrackRef",15:"GPSTrack",16:"GPSImgDirectionRef",17:"GPSImgDirection",18:"GPSMapDatum",19:"GPSDestLatitudeRef",20:"GPSDestLatitude",21:"GPSDestLongitudeRef",22:"GPSDestLongitude",23:"GPSDestBearingRef",24:"GPSDestBearing",25:"GPSDestDistanceRef",26:"GPSDestDistance",27:"GPSProcessingMethod",28:"GPSAreaInformation",29:"GPSDateStamp",30:"GPSDifferential"},b=m.StringValues={ExposureProgram:{0:"Not defined",1:"Manual",2:"Normal program",3:"Aperture priority",4:"Shutter priority",5:"Creative program",6:"Action program",7:"Portrait mode",8:"Landscape mode"},MeteringMode:{0:"Unknown",1:"Average",2:"CenterWeightedAverage",3:"Spot",4:"MultiSpot",5:"Pattern",6:"Partial",255:"Other"},LightSource:{0:"Unknown",1:"Daylight",2:"Fluorescent",3:"Tungsten (incandescent light)",4:"Flash",9:"Fine weather",10:"Cloudy weather",11:"Shade",12:"Daylight fluorescent (D 5700 - 7100K)",13:"Day white fluorescent (N 4600 - 5400K)",14:"Cool white fluorescent (W 3900 - 4500K)",15:"White fluorescent (WW 3200 - 3700K)",17:"Standard light A",18:"Standard light B",19:"Standard light C",20:"D55",21:"D65",22:"D75",23:"D50",24:"ISO studio tungsten",255:"Other"},Flash:{0:"Flash did not fire",1:"Flash fired",5:"Strobe return light not detected",7:"Strobe return light detected",9:"Flash fired, compulsory flash mode",13:"Flash fired, compulsory flash mode, return light not detected",15:"Flash fired, compulsory flash mode, return light detected",16:"Flash did not fire, compulsory flash mode",24:"Flash did not fire, auto mode",25:"Flash fired, auto mode",29:"Flash fired, auto mode, return light not detected",31:"Flash fired, auto mode, return light detected",32:"No flash function",65:"Flash fired, red-eye reduction mode",69:"Flash fired, red-eye reduction mode, return light not detected",71:"Flash fired, red-eye reduction mode, return light detected",73:"Flash fired, compulsory flash mode, red-eye reduction mode",77:"Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected",79:"Flash fired, compulsory flash mode, red-eye reduction mode, return light detected",89:"Flash fired, auto mode, red-eye reduction mode",93:"Flash fired, auto mode, return light not detected, red-eye reduction mode",95:"Flash fired, auto mode, return light detected, red-eye reduction mode"},SensingMethod:{1:"Not defined",2:"One-chip color area sensor",3:"Two-chip color area sensor",4:"Three-chip color area sensor",5:"Color sequential area sensor",7:"Trilinear sensor",8:"Color sequential linear sensor"},SceneCaptureType:{0:"Standard",1:"Landscape",2:"Portrait",3:"Night scene"},SceneType:{1:"Directly photographed"},CustomRendered:{0:"Normal process",1:"Custom process"},WhiteBalance:{0:"Auto white balance",1:"Manual white balance"},GainControl:{0:"None",1:"Low gain up",2:"High gain up",3:"Low gain down",4:"High gain down"},Contrast:{0:"Normal",1:"Soft",2:"Hard"},Saturation:{0:"Normal",1:"Low saturation",2:"High saturation"},Sharpness:{0:"Normal",1:"Soft",2:"Hard"},SubjectDistanceRange:{0:"Unknown",1:"Macro",2:"Close view",3:"Distant view"},FileSource:{3:"DSC"},Components:{0:"",1:"Y",2:"Cb",3:"Cr",4:"R",5:"G",6:"B"}},S={120:"caption",110:"credit",25:"keywords",55:"dateCreated",80:"byline",85:"bylineTitle",122:"captionWriter",105:"headline",116:"copyright",15:"category"};m.getData=function(e,t){return(e instanceof Image||e instanceof HTMLImageElement)&&!e.complete?!1:(n(e)?t&&t.call(e):s(e,t),!0)},m.getTag=function(e,t){return n(e)?e.exifdata[t]:void 0},m.getAllTags=function(e){if(!n(e)){ return{}; }var t,r=e.exifdata,i={};for(t in r){ r.hasOwnProperty(t)&&(i[t]=r[t]); }return i},m.pretty=function(e){if(!n(e)){ return""; }var t,r=e.exifdata,i="";for(t in r){ r.hasOwnProperty(t)&&(i+="object"==typeof r[t]?r[t]instanceof Number?t+" : "+r[t]+" ["+r[t].numerator+"/"+r[t].denominator+"]\r\n":t+" : ["+r[t].length+" values]\r\n":t+" : "+r[t]+"\r\n"); }return i},m.readFromBinaryFile=function(e){return u(e)},r=[],i=function(){return m}.apply(t,r),!(void 0!==i&&(e.exports=i));}).call(this);},function(e,t,n){var r,i;!function(){function n(e){var t=e.naturalWidth,n=e.naturalHeight;if(t*n>1048576){var r=document.createElement("canvas");r.width=r.height=1;var i=r.getContext("2d");return i.drawImage(e,-t+1,0),0===i.getImageData(0,0,1,1).data[3]}return!1}function o(e,t,n){var r=document.createElement("canvas");r.width=1,r.height=n;var i=r.getContext("2d");i.drawImage(e,0,0);for(var o=i.getImageData(0,0,1,n).data,a=0,s=n,u=n;u>a;){var c=o[4*(u-1)+3];0===c?s=u:a=u,u=s+a>>1;}var l=u/n;return 0===l?1:l}function a(e,t,n){var r=document.createElement("canvas");return s(e,r,t,n),r.toDataURL("image/jpeg",t.quality||.8)}function s(e,t,r,i){var a=e.naturalWidth,s=e.naturalHeight,c=r.width,l=r.height,f=t.getContext("2d");f.save(),u(t,f,c,l,r.orientation);var d=n(e);d&&(a/=2,s/=2);var h=1024,g=document.createElement("canvas");g.width=g.height=h;for(var p=g.getContext("2d"),m=i?o(e,a,s):1,w=Math.ceil(h*c/a),v=Math.ceil(h*l/s/m),y=0,b=0;s>y;){for(var S=0,I=0;a>S;){ p.clearRect(0,0,h,h),p.drawImage(e,-S,-y),f.drawImage(g,0,0,h,h,I,b,w,v),S+=h,I+=w; }y+=h,b+=v;}f.restore(),g=p=null;}function u(e,t,n,r,i){switch(i){case 5:case 6:case 7:case 8:e.width=r,e.height=n;break;default:e.width=n,e.height=r;}switch(i){case 2:t.translate(n,0),t.scale(-1,1);break;case 3:t.translate(n,r),t.rotate(Math.PI);break;case 4:t.translate(0,r),t.scale(1,-1);break;case 5:t.rotate(.5*Math.PI),t.scale(1,-1);break;case 6:t.rotate(.5*Math.PI),t.translate(0,-r);break;case 7:t.rotate(.5*Math.PI),t.translate(n,-r),t.scale(-1,1);break;case 8:t.rotate(-.5*Math.PI),t.translate(-n,0);}}function c(e){if(window.Blob&&e instanceof Blob){var t=new Image,n=window.URL&&window.URL.createObjectURL?window.URL:window.webkitURL&&window.webkitURL.createObjectURL?window.webkitURL:null;if(!n){ throw Error("No createObjectURL function found to create blob url"); }t.src=n.createObjectURL(e),this.blob=e,e=t;}if(!e.naturalWidth&&!e.naturalHeight){var r=this;e.onload=function(){var e=r.imageLoadListeners;if(e){r.imageLoadListeners=null;for(var t=0,n=e.length;n>t;t++){ e[t](); }}},this.imageLoadListeners=[];}this.srcImage=e;}c.prototype.render=function(e,t,n){if(this.imageLoadListeners){var r=this;return void this.imageLoadListeners.push(function(){r.render(e,t,n);})}t=t||{};var i=this.srcImage,o=i.src,u=o.length,c=i.naturalWidth,l=i.naturalHeight,f=t.width,d=t.height,h=t.maxWidth,g=t.maxHeight,p=this.blob&&"image/jpeg"===this.blob.type||0===o.indexOf("data:image/jpeg")||o.indexOf(".jpg")===u-4||o.indexOf(".jpeg")===u-5;f&&!d?d=l*f/c<<0:d&&!f?f=c*d/l<<0:(f=c,d=l),h&&f>h&&(f=h,d=l*f/c<<0),g&&d>g&&(d=g,f=c*d/l<<0);var m={width:f,height:d};for(var w in t){ m[w]=t[w]; }var v=e.tagName.toLowerCase();"img"===v?e.src=a(this.srcImage,m,p):"canvas"===v&&s(this.srcImage,e,m,p),"function"==typeof this.onrender&&this.onrender(e),n&&n();},r=[],i=function(){return c}.apply(t,r),!(void 0!==i&&(e.exports=i));}();},function(e,t){function n(e){function t(e){for(var t=[16,11,10,16,24,40,51,61,12,12,14,19,26,58,60,55,14,13,16,24,40,57,69,56,14,17,22,29,51,87,80,62,18,22,37,56,68,109,103,77,24,35,55,64,81,104,113,92,49,64,78,87,103,121,120,101,72,92,95,98,112,100,103,99],n=0;64>n;n++){var r=F((t[n]*e+50)/100);1>r?r=1:r>255&&(r=255),D[N[n]]=r;}for(var i=[17,18,24,47,99,99,99,99,18,21,26,66,99,99,99,99,24,26,56,99,99,99,99,99,47,66,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99,99],o=0;64>o;o++){var a=F((i[o]*e+50)/100);1>a?a=1:a>255&&(a=255),x[N[o]]=a;}for(var s=[1,1.387039845,1.306562965,1.175875602,1,.785694958,.5411961,.275899379],u=0,c=0;8>c;c++){ for(var l=0;8>l;l++){ U[u]=1/(D[N[u]]*s[c]*s[l]*8),C[u]=1/(x[N[u]]*s[c]*s[l]*8),u++; } }}function n(e,t){for(var n=0,r=0,i=new Array,o=1;16>=o;o++){for(var a=1;a<=e[o];a++){ i[t[r]]=[],i[t[r]][0]=n,i[t[r]][1]=o,r++,n++; }n*=2;}return i}function r(){y=n(W,H),b=n(V,X),S=n(z,q),I=n(Q,Y);}function i(){for(var e=1,t=2,n=1;15>=n;n++){for(var r=e;t>r;r++){ A[32767+r]=n,T[32767+r]=[],T[32767+r][1]=n,T[32767+r][0]=r; }for(var i=-(t-1);-e>=i;i++){ A[32767+i]=n,T[32767+i]=[],T[32767+i][1]=n,T[32767+i][0]=t-1+i; }e<<=1,t<<=1;}}function o(){for(var e=0;256>e;e++){ k[e]=19595*e,k[e+256>>0]=38470*e,k[e+512>>0]=7471*e+32768,k[e+768>>0]=-11059*e,k[e+1024>>0]=-21709*e,k[e+1280>>0]=32768*e+8421375,k[e+1536>>0]=-27439*e,k[e+1792>>0]=-5329*e; }}function a(e){for(var t=e[0],n=e[1]-1;n>=0;){ t&1<<n&&(G|=1<<O),n--,O--,0>O&&(255==G?(s(255),s(0)):s(G),O=7,G=0); }}function s(e){M.push(j[e]);}function u(e){s(e>>8&255),s(255&e);}function c(e,t){var n,r,i,o,a,s,u,c,l,f=0;var d=8,h=64;for(l=0;d>l;++l){n=e[f],r=e[f+1],i=e[f+2],o=e[f+3],a=e[f+4],s=e[f+5],u=e[f+6],c=e[f+7];var g=n+c,p=n-c,m=r+u,w=r-u,v=i+s,y=i-s,b=o+a,S=o-a,I=g+b,P=g-b,F=m+v,D=m-v;e[f]=I+F,e[f+4]=I-F;var x=.707106781*(D+P);e[f+2]=P+x,e[f+6]=P-x,I=S+y,F=y+w,D=w+p;var U=.382683433*(I-D),C=.5411961*I+U,T=1.306562965*D+U,A=.707106781*F,R=p+A,M=p-A;e[f+5]=M+C,e[f+3]=M-C,e[f+1]=R+T,e[f+7]=R-T,f+=8;}for(f=0,l=0;d>l;++l){n=e[f],r=e[f+8],i=e[f+16],o=e[f+24],a=e[f+32],s=e[f+40],u=e[f+48],c=e[f+56];var G=n+c,O=n-c,_=r+u,B=r-u,E=i+s,j=i-s,k=o+a,N=o-a,W=G+k,H=G-k,z=_+E,q=_-E;e[f]=W+z,e[f+32]=W-z;var V=.707106781*(q+H);e[f+16]=H+V,e[f+48]=H-V,W=N+j,z=j+B,q=B+O;var X=.382683433*(W-q),Q=.5411961*W+X,Y=1.306562965*q+X,K=.707106781*z,J=O+K,Z=O-K;e[f+40]=Z+Q,e[f+24]=Z-Q,e[f+8]=J+Y,e[f+56]=J-Y,f++;}var $;for(l=0;h>l;++l){ $=e[l]*t[l],L[l]=$>0?$+.5|0:$-.5|0; }return L}function l(){u(65504),u(16),s(74),s(70),s(73),s(70),s(0),s(1),s(1),s(0),u(1),u(1),s(0),s(0);}function f(e,t){u(65472),u(17),s(8),u(t),u(e),s(3),s(1),s(17),s(0),s(2),s(17),s(1),s(3),s(17),s(1);}function d(){u(65499),u(132),s(0);for(var e=0;64>e;e++){ s(D[e]); }s(1);for(var t=0;64>t;t++){ s(x[t]); }}function h(){u(65476),u(418),s(0);for(var e=0;16>e;e++){ s(W[e+1]); }for(var t=0;11>=t;t++){ s(H[t]); }s(16);for(var n=0;16>n;n++){ s(z[n+1]); }for(var r=0;161>=r;r++){ s(q[r]); }s(1);for(var i=0;16>i;i++){ s(V[i+1]); }for(var o=0;11>=o;o++){ s(X[o]); }s(17);for(var a=0;16>a;a++){ s(Q[a+1]); }for(var c=0;161>=c;c++){ s(Y[c]); }}function g(){u(65498),u(12),s(3),s(1),s(0),s(2),s(17),s(3),s(17),s(0),s(63),s(0);}function p(e,t,n,r,i){var o,s=i[0],u=i[240];var l=16,f=63,d=64;for(var h=c(e,t),g=0;d>g;++g){ R[N[g]]=h[g]; }var p=R[0]-n;n=R[0],0==p?a(r[0]):(o=32767+p,a(r[A[o]]),a(T[o]));for(var m=63;m>0&&0==R[m];m--){ }if(0==m){ return a(s),n; }for(var w,v=1;m>=v;){for(var y=v;0==R[v]&&m>=v;++v){ }var b=v-y;if(b>=l){w=b>>4;for(var S=1;w>=S;++S){ a(u); }b=15&b;}o=32767+R[v],a(i[(b<<4)+A[o]]),a(T[o]),v++;}return m!=f&&a(s),n}function m(){for(var e=String.fromCharCode,t=0;256>t;t++){ j[t]=e(t); }}function w(e){if(0>=e&&(e=1),e>100&&(e=100),P!=e){var n=0;n=50>e?Math.floor(5e3/e):Math.floor(200-2*e),t(n),P=e;}}function v(){var t=(new Date).getTime();e||(e=50),m(),r(),i(),o(),w(e);(new Date).getTime()-t;}var y,b,S,I,P,F=(Math.round,Math.floor),D=new Array(64),x=new Array(64),U=new Array(64),C=new Array(64),T=new Array(65535),A=new Array(65535),L=new Array(64),R=new Array(64),M=[],G=0,O=7,_=new Array(64),B=new Array(64),E=new Array(64),j=new Array(256),k=new Array(2048),N=[0,1,5,6,14,15,27,28,2,4,7,13,16,26,29,42,3,8,12,17,25,30,41,43,9,11,18,24,31,40,44,53,10,19,23,32,39,45,52,54,20,22,33,38,46,51,55,60,21,34,37,47,50,56,59,61,35,36,48,49,57,58,62,63],W=[0,0,1,5,1,1,1,1,1,1,0,0,0,0,0,0,0],H=[0,1,2,3,4,5,6,7,8,9,10,11],z=[0,0,2,1,3,3,2,4,3,5,5,4,4,0,0,1,125],q=[1,2,3,0,4,17,5,18,33,49,65,6,19,81,97,7,34,113,20,50,129,145,161,8,35,66,177,193,21,82,209,240,36,51,98,114,130,9,10,22,23,24,25,26,37,38,39,40,41,42,52,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,225,226,227,228,229,230,231,232,233,234,241,242,243,244,245,246,247,248,249,250],V=[0,0,3,1,1,1,1,1,1,1,1,1,0,0,0,0,0],X=[0,1,2,3,4,5,6,7,8,9,10,11],Q=[0,0,2,1,2,4,4,3,4,7,5,4,4,0,1,2,119],Y=[0,1,2,3,17,4,5,33,49,6,18,65,81,7,97,113,19,34,50,129,8,20,66,145,161,177,193,9,35,51,82,240,21,98,114,209,10,22,36,52,225,37,241,23,24,25,26,38,39,40,41,42,53,54,55,56,57,58,67,68,69,70,71,72,73,74,83,84,85,86,87,88,89,90,99,100,101,102,103,104,105,106,115,116,117,118,119,120,121,122,130,131,132,133,134,135,136,137,138,146,147,148,149,150,151,152,153,154,162,163,164,165,166,167,168,169,170,178,179,180,181,182,183,184,185,186,194,195,196,197,198,199,200,201,202,210,211,212,213,214,215,216,217,218,226,227,228,229,230,231,232,233,234,242,243,244,245,246,247,248,249,250];this.encode=function(e,t,n){var r=(new Date).getTime();t&&w(t),M=new Array,G=0,O=7,u(65496),l(),d(),f(e.width,e.height),h(),g();var i=0,o=0,s=0;G=0,O=7,this.encode.displayName="_encode_";for(var c,m,v,P,F,D,x,T,A,L=e.data,R=e.width,j=e.height,N=4*R,W=0;j>W;){for(c=0;N>c;){for(F=N*W+c,D=F,x=-1,T=0,A=0;64>A;A++){ T=A>>3,x=4*(7&A),D=F+T*N+x,W+T>=j&&(D-=N*(W+1+T-j)),c+x>=N&&(D-=c+x-N+4),m=L[D++],v=L[D++],P=L[D++],_[A]=(k[m]+k[v+256>>0]+k[P+512>>0]>>16)-128,B[A]=(k[m+768>>0]+k[v+1024>>0]+k[P+1280>>0]>>16)-128,E[A]=(k[m+1280>>0]+k[v+1536>>0]+k[P+1792>>0]>>16)-128; }i=p(_,U,i,y,S),o=p(B,C,o,b,I),s=p(E,C,s,b,I),c+=32;}W+=8;}if(O>=0){var H=[];H[1]=O+1,H[0]=(1<<O+1)-1,a(H);}if(u(65497),n){for(var z=M.length,q=new Uint8Array(z),V=0;z>V;V++){ q[V]=M[V].charCodeAt(); }M=[];(new Date).getTime()-r;return q}var X="data:image/jpeg;base64,"+btoa(M.join(""));M=[];(new Date).getTime()-r;return X},v();}e.exports=n;},function(e,t,n){function r(e,t){var n=this;if(!e){ throw new Error("没有收到图片,可能的解决方案:https://github.com/think2011/localResizeIMG/issues/7"); }t=t||{},n.defaults={width:null,height:null,fieldName:"file",quality:.7},n.file=e;for(var r in t){ t.hasOwnProperty(r)&&(n.defaults[r]=t[r]); }return this.init()}function i(e){var t=null;return t=e?[].filter.call(document.scripts,function(t){return-1!==t.src.indexOf(e)})[0]:document.scripts[document.scripts.length-1],t?t.src.substr(0,t.src.lastIndexOf("/")):null}function o(e){var t;t=e.split(",")[0].indexOf("base64")>=0?atob(e.split(",")[1]):unescape(e.split(",")[1]);for(var n=e.split(",")[0].split(":")[1].split(";")[0],r=new Uint8Array(t.length),i=0;i<t.length;i++){ r[i]=t.charCodeAt(i); }return new s.Blob([r.buffer],{type:n})}n.p=i("lrz")+"/",window.URL=window.URL||window.webkitURL;var a=n(1),s=n(4),u=n(5),c=function(e){var t=/OS (\d)_.* like Mac OS X/g.exec(e),n=/Android (\d.*?);/g.exec(e)||/Android\/(\d.*?) /g.exec(e);return{oldIOS:t?+t.pop()<8:!1,oldAndroid:n?+n.pop().substr(0,3)<4.5:!1,iOS:/\(i[^;]+;( U;)? CPU.+Mac OS X/.test(e),android:/Android/g.test(e),mQQBrowser:/MQQBrowser/g.test(e)}}(navigator.userAgent);r.prototype.init=function(){var e=this,t=e.file,n="string"==typeof t,r=/^data:/.test(t),i=new Image,u=document.createElement("canvas"),c=n?t:URL.createObjectURL(t);if(e.img=i,e.blob=c,e.canvas=u,n?e.fileName=r?"base64.jpg":t.split("/").pop():e.fileName=t.name,!document.createElement("canvas").getContext){ throw new Error("浏览器不支持canvas"); }return new a(function(n,a){i.onerror=function(){var e=new Error("加载图片文件失败");throw a(e),e},i.onload=function(){e._getBase64().then(function(e){if(e.length<10){var t=new Error("生成base64失败");throw a(t),t}return e}).then(function(r){var i=null;"object"==typeof e.file&&r.length>e.file.size?(i=new FormData,t=e.file):(i=new s.FormData,t=o(r)),i.append(e.defaults.fieldName,t,e.fileName.replace(/\..+/g,".jpg")),n({formData:i,fileLen:+t.size,base64:r,base64Len:r.length,origin:e.file,file:t});for(var a in e){ e.hasOwnProperty(a)&&(e[a]=null); }URL.revokeObjectURL(e.blob);});},!r&&(i.crossOrigin="*"),i.src=c;})},r.prototype._getBase64=function(){var e=this,t=e.img,n=e.file,r=e.canvas;return new a(function(i){try{u.getData("object"==typeof n?n:t,function(){e.orientation=u.getTag(this,"Orientation"),e.resize=e._getResize(),e.ctx=r.getContext("2d"),r.width=e.resize.width,r.height=e.resize.height,e.ctx.fillStyle="#fff",e.ctx.fillRect(0,0,r.width,r.height),c.oldIOS?e._createBase64ForOldIOS().then(i):e._createBase64().then(i);});}catch(o){throw new Error(o)}})},r.prototype._createBase64ForOldIOS=function(){var e=this,t=e.img,r=e.canvas,i=e.defaults,o=e.orientation;return new a(function(e){!function(){var a=[n(6)];(function(n){var a=new n(t);"5678".indexOf(o)>-1?a.render(r,{width:r.height,height:r.width,orientation:o}):a.render(r,{width:r.width,height:r.height,orientation:o}),e(r.toDataURL("image/jpeg",i.quality));}).apply(null,a);}();})},r.prototype._createBase64=function(){var e=this,t=e.resize,r=e.img,i=e.canvas,o=e.ctx,s=e.defaults,u=e.orientation;switch(u){case 3:o.rotate(180*Math.PI/180),o.drawImage(r,-t.width,-t.height,t.width,t.height);break;case 6:o.rotate(90*Math.PI/180),o.drawImage(r,0,-t.width,t.height,t.width);break;case 8:o.rotate(270*Math.PI/180),o.drawImage(r,-t.height,0,t.height,t.width);break;case 2:o.translate(t.width,0),o.scale(-1,1),o.drawImage(r,0,0,t.width,t.height);break;case 4:o.translate(t.width,0),o.scale(-1,1),o.rotate(180*Math.PI/180),o.drawImage(r,-t.width,-t.height,t.width,t.height);break;case 5:o.translate(t.width,0),o.scale(-1,1),o.rotate(90*Math.PI/180),o.drawImage(r,0,-t.width,t.height,t.width);break;case 7:o.translate(t.width,0),o.scale(-1,1),o.rotate(270*Math.PI/180),o.drawImage(r,-t.height,0,t.height,t.width);break;default:o.drawImage(r,0,0,t.width,t.height);}return new a(function(e){c.oldAndroid||c.mQQBrowser||!navigator.userAgent?!function(){var t=[n(7)];(function(t){var n=new t,r=o.getImageData(0,0,i.width,i.height);e(n.encode(r,100*s.quality));}).apply(null,t);}():e(i.toDataURL("image/jpeg",s.quality));})},r.prototype._getResize=function(){var e=this,t=e.img,n=e.defaults,r=n.width,i=n.height,o=e.orientation,a={width:t.width,height:t.height};if("5678".indexOf(o)>-1&&(a.width=t.height,a.height=t.width),a.width<r||a.height<i){ return a; }var s=a.width/a.height;for(r&&i?s>=r/i?a.width>r&&(a.width=r,a.height=Math.ceil(r/s)):a.height>i&&(a.height=i,a.width=Math.ceil(i*s)):r?r<a.width&&(a.width=r,a.height=Math.ceil(r/s)):i&&i<a.height&&(a.width=Math.ceil(i*s),a.height=i);a.width>=3264||a.height>=2448;){ a.width*=.8,a.height*=.8; }return a},window.lrz=function(e,t){return new r(e,t)},window.lrz.version="4.9.40",
  276. e.exports=window.lrz;}])});
  277. });
  278. var template$3 = "<div> <div v-show=\"upload.status=='ready'\"> <input type=\"text\" v-model=\"imageUrl\" maxlength=\"255\" :placeholder=\"$parent.locale['please enter a url']\"> <button type=\"button\" @click=\"insertImageUrl\">{{$parent.locale.save}}</button> <input type=\"file\" ref=\"file\" style=\"display: none !important\" @change=\"process\" accept=\"image/png,image/jpeg,image/gif,image/jpg\"> <button type=\"button\" @click=\"pick\">{{$parent.locale.upload}}</button> </div> <div v-if=\"upload.status=='progress'\"> {{$parent.locale.progress}}:{{upload.progressComputable ? $parent.locale.unknown : upload.complete}} </div> <div v-if=\"upload.status=='success'\"> {{$parent.locale[\"please wait\"]}}... </div> <div v-if=\"upload.status=='error'\"> {{$parent.locale.error}}:{{upload.errorMsg}} <button type=\"button\" @click=\"reset\">{{$parent.locale.reset}}</button> </div> <div v-if=\"upload.status=='abort'\"> {{$parent.locale.upload}}&nbsp;{{$parent.locale.abort}}, <button type=\"button\" @click=\"reset\">{{$parent.locale.reset}}</button> </div> </div> ";
  279. /**
  280. * Created by peak on 2017/2/10.
  281. */
  282. var dashboard$3 = {
  283. template: template$3,
  284. data: function data() {
  285. return {
  286. imageUrl: '',
  287. upload: {
  288. status: 'ready', // progress,success,error,abort
  289. errorMsg: null,
  290. progressComputable: false,
  291. complete: 0
  292. }
  293. }
  294. },
  295. methods: {
  296. reset: function reset(){
  297. this.upload.status = 'ready';
  298. },
  299. insertImageUrl: function insertImageUrl() {
  300. if (!this.imageUrl) {
  301. return
  302. }
  303. this.$parent.execCommand(Command.INSERT_IMAGE, this.imageUrl);
  304. this.imageUrl = null;
  305. },
  306. pick: function pick() {
  307. this.$refs.file.click();
  308. },
  309. setUploadError: function setUploadError(msg){
  310. this.upload.status = 'error';
  311. this.upload.errorMsg = msg;
  312. },
  313. process: function process() {
  314. var this$1 = this;
  315. var component = this;
  316. var config = this.$options.module.config;
  317. // compatibility with older format
  318. // {
  319. // server: null,
  320. // fieldName: 'image',
  321. // compress: true,
  322. // width: 1600,
  323. // height: 1600,
  324. // quality: 80
  325. // }
  326. // ----------- divider ----------------
  327. // {
  328. // upload: {
  329. // url: null,
  330. // headers: {},
  331. // params: {},
  332. // fieldName: {}
  333. // },
  334. // compress: {
  335. // width: 1600,
  336. // height: 1600,
  337. // quality: 80
  338. // },
  339. // }
  340. if (!config.upload && typeof config.server === 'string') {
  341. config.upload = {url: config.server};
  342. }
  343. if (config.upload && !config.upload.url) {
  344. config.upload = null;
  345. }
  346. if (config.upload && typeof config.fieldName === 'string') {
  347. config.upload.fieldName = config.fieldName;
  348. }
  349. if (typeof config.compress === 'boolean') {
  350. config.compress = {
  351. width: config.width,
  352. height: config.height,
  353. quality: config.quality
  354. };
  355. }
  356. var file = this.$refs.file.files[0];
  357. if (file.size > config.sizeLimit) {
  358. this.setUploadError(this.$parent.locale['exceed size limit']);
  359. return
  360. }
  361. this.$refs.file.value = null;
  362. if (config.compress) {
  363. config.compress.fieldName = config.upload && config.upload.fieldName
  364. ? config.upload.fieldName : 'image';
  365. lrz_all_bundle(file, config.compress).then(function (rst) {
  366. if (config.upload) {
  367. component.uploadToServer(rst.file);
  368. } else {
  369. component.insertBase64(rst.base64);
  370. }
  371. }).catch(function (err) {
  372. this$1.setUploadError(err.toString());
  373. });
  374. return
  375. }
  376. // 不需要压缩
  377. // base64
  378. if (!config.upload) {
  379. var reader = new FileReader();
  380. reader.onload = function (e) {
  381. component.insertBase64(e.target.result);
  382. };
  383. reader.readAsDataURL(file);
  384. return
  385. }
  386. // 上传服务器
  387. component.uploadToServer(file);
  388. },
  389. insertBase64: function insertBase64(data) {
  390. this.$parent.execCommand(Command.INSERT_IMAGE, data);
  391. },
  392. uploadToServer: function uploadToServer(file) {
  393. var this$1 = this;
  394. var config = this.$options.module.config;
  395. var formData = new FormData();
  396. formData.append(config.upload.fieldName || 'image', file);
  397. if (typeof config.upload.params === 'object') {
  398. Object.keys(config.upload.params).forEach(function (key) {
  399. var value = config.upload.params[key];
  400. if (Array.isArray(value)) {
  401. value.forEach(function (v) {
  402. formData.append(key, v);
  403. });
  404. } else {
  405. formData.append(key, value);
  406. }
  407. });
  408. }
  409. var xhr = new XMLHttpRequest();
  410. xhr.onprogress = function (e) {
  411. this$1.upload.status = 'progress';
  412. if (e.lengthComputable) {
  413. this$1.upload.progressComputable = true;
  414. var percentComplete = e.loaded / e.total;
  415. this$1.upload.complete = (percentComplete * 100).toFixed(2);
  416. } else {
  417. this$1.upload.progressComputable = false;
  418. }
  419. };
  420. xhr.onload = function () {
  421. if (xhr.status >= 300) {
  422. this$1.setUploadError(("request error,code " + (xhr.status)));
  423. return
  424. }
  425. try {
  426. var url = config.uploadHandler(xhr.responseText);
  427. if (url) {
  428. this$1.$parent.execCommand(Command.INSERT_IMAGE, url);
  429. }
  430. } catch (err) {
  431. this$1.setUploadError(err.toString());
  432. } finally {
  433. this$1.upload.status = 'ready';
  434. }
  435. };
  436. xhr.onerror = function () {
  437. // find network info in brower tools
  438. this$1.setUploadError('request error');
  439. };
  440. xhr.onabort = function () {
  441. this$1.upload.status = 'abort';
  442. };
  443. xhr.open('POST', config.upload.url);
  444. if (typeof config.upload.headers === 'object') {
  445. Object.keys(config.upload.headers).forEach(function (k) {
  446. xhr.setRequestHeader(k, config.upload.headers[k]);
  447. });
  448. }
  449. xhr.send(formData);
  450. }
  451. }
  452. };
  453. /**
  454. * insert image
  455. * Created by peak on 16/8/18.
  456. */
  457. var image = {
  458. name: 'image',
  459. icon: 'fa fa-file-image-o',
  460. i18n: 'image',
  461. config: {
  462. // server: null,
  463. // fieldName: 'image',
  464. // compress: true,
  465. // width: 1600,
  466. // height: 1600,
  467. // quality: 80,
  468. sizeLimit: 512 * 1024,// 512k
  469. // upload: {
  470. // url: null,
  471. // headers: {},
  472. // params: {},
  473. // fieldName: {}
  474. // },
  475. compress: {
  476. width: 1600,
  477. height: 1600,
  478. quality: 80
  479. },
  480. uploadHandler: function uploadHandler(responseText){
  481. var json = JSON.parse(responseText);
  482. return json.ok ? json.data : null
  483. }
  484. },
  485. dashboard: dashboard$3
  486. };
  487. var template$4 = "<div> <h3 style=\"text-align: center\">Vue-html5-editor&nbsp;{{version}}</h3> <p style=\"text-align: center\"> repository: <a href=\"https://github.com/PeakTai/vue-html5-editor\" target=\"_blank\"> https://github.com/PeakTai/vue-html5-editor </a> </p> </div> ";
  488. /**
  489. * Created by peak on 2017/2/10.
  490. */
  491. var dashboard$4 = {
  492. template: template$4,
  493. data: function data(){
  494. return {
  495. version: "1.1.1"
  496. }
  497. }
  498. };
  499. /**
  500. * editor info
  501. * Created by peak on 16/8/18.
  502. */
  503. var info = {
  504. name: 'info',
  505. icon: 'fa fa-info',
  506. i18n: 'info',
  507. // handler () {
  508. //
  509. // },
  510. // init (editor) {
  511. //
  512. // },
  513. // destroyed(editor){
  514. //
  515. // },
  516. dashboard: dashboard$4
  517. };
  518. var template$5 = "<form @submit.prevent=\"createLink\"> <input type=\"text\" :placeholder=\"$parent.locale['please enter a url']\" v-model=\"url\" maxlength=\"1024\"> <button type=\"submit\">{{$parent.locale[\"create link\"]}}</button> </form>";
  519. var dashboard$5 = {
  520. template: template$5,
  521. data: function data(){
  522. return {url: null}
  523. },
  524. methods: {
  525. createLink: function createLink(){
  526. if (!this.url) {
  527. return
  528. }
  529. this.$parent.execCommand('createLink', this.url);
  530. this.url = null;
  531. }
  532. }
  533. };
  534. /**
  535. * create link
  536. * Created by peak on 16/8/18.
  537. */
  538. var link = {
  539. name: 'link',
  540. icon: 'fa fa-chain',
  541. i18n: 'link',
  542. dashboard: dashboard$5
  543. };
  544. var template$6 = "<div> <button type=\"button\" @click=\"$parent.execCommand('insertOrderedList')\"> {{$parent.locale[\"ordered list\"]}} </button> <button type=\"button\" @click=\"$parent.execCommand('insertUnorderedList')\"> {{$parent.locale[\"unordered list\"]}} </button> </div>";
  545. /**
  546. * Created by peak on 2017/2/10.
  547. */
  548. var dashboard$6 = {
  549. template: template$6
  550. };
  551. /**
  552. * list,ul,ol
  553. * Created by peak on 16/8/18.
  554. */
  555. var list = {
  556. name: 'list',
  557. icon: 'fa fa-list',
  558. i18n: 'list',
  559. dashboard: dashboard$6
  560. };
  561. var template$7 = "<form @submit.prevent=\"insertTable\"> <label> {{$parent.locale[\"row count\"]}} <input type=\"number\" style=\"width: 60px\" maxlength=\"2\" min=\"2\" max=\"10\" v-model=\"rows\"> </label> <label> {{$parent.locale[\"column count\"]}} <input type=\"number\" style=\"width: 60px\" maxlength=\"2\" min=\"2\" max=\"10\" v-model=\"cols\"> </label> <button type=\"submit\">{{$parent.locale.save}}</button> </form>";
  562. /**
  563. * Created by peak on 2017/2/10.
  564. */
  565. var dashboard$7 = {
  566. template: template$7,
  567. data: function data(){
  568. return {
  569. rows: 2,
  570. cols: 2,
  571. hasHead: false,
  572. striped: false,
  573. hover: false
  574. }
  575. },
  576. methods: {
  577. insertTable: function insertTable(){
  578. if (this.rows < 2 || this.rows > 10) {
  579. return
  580. }
  581. if (this.cols < 2 || this.cols > 10) {
  582. return
  583. }
  584. var table = '<table style="border-spacing: 0px; border-collapse: collapse; width: 100%; max-width: 100%; margin-bottom: 0px; border: 1px solid rgb(221, 221, 221); color: rgb(51, 51, 51); font-size: 14px; line-height: 20px; background-color: transparent;"><tbody>';
  585. for (var i = 0; i < this.rows; i++) {
  586. table += '<tr>';
  587. for (var j = 0; j < this.cols; j++) {
  588. table += '<td style="padding: 8px; line-height: 1.42857; vertical-align: top; border: 1px solid rgb(221, 221, 221);">&nbsp;</td>';
  589. }
  590. table += '</tr>';
  591. }
  592. table += '</tbody></table>';
  593. this.$parent.execCommand('insertHTML', table);
  594. }
  595. }
  596. };
  597. /**
  598. * insert table
  599. * Created by peak on 16/8/18.
  600. */
  601. var table = {
  602. // can not named table
  603. // dashboard.html will add to editor as a child component and named as module name
  604. // Do not use built-in or reserved HTML elements as component id
  605. name: 'tabulation',
  606. icon: 'fa fa-table',
  607. i18n: 'table',
  608. dashboard: dashboard$7
  609. };
  610. var template$8 = "<div> <button type=\"button\" @click=\"$parent.execCommand('bold')\">{{$parent.locale[\"bold\"]}}</button> <button type=\"button\" @click=\"$parent.execCommand('italic')\">{{$parent.locale[\"italic\"]}}</button> <button type=\"button\" @click=\"$parent.execCommand('underline')\">{{$parent.locale[\"underline\"]}}</button> <button type=\"button\" @click=\"$parent.execCommand('strikeThrough')\">{{$parent.locale[\"strike through\"]}} </button> <button type=\"button\" @click=\"$parent.execCommand('subscript')\">{{$parent.locale[\"subscript\"]}}</button> <button type=\"button\" @click=\"$parent.execCommand('superscript')\">{{$parent.locale[\"superscript\"]}}</button> </div> ";
  611. var dashboard$8 = {
  612. template: template$8
  613. };
  614. /**
  615. * text,set the text bold or italic or underline or with strike through or subscript or superscript
  616. * Created by peak on 16/8/18.
  617. */
  618. var text = {
  619. name: 'text',
  620. icon: 'fa fa-pencil',
  621. i18n: 'text',
  622. dashboard: dashboard$8
  623. };
  624. /**
  625. * undo
  626. * Created by peak on 16/8/20.
  627. */
  628. var undo = {
  629. name: 'undo',
  630. icon: 'fa-undo fa',
  631. i18n: 'undo',
  632. handler: function handler(editor) {
  633. editor.execCommand('undo');
  634. }
  635. };
  636. /**
  637. * unlink
  638. * Created by peak on 16/8/18.
  639. */
  640. var unlink = {
  641. name: 'unlink',
  642. icon: 'fa fa-chain-broken',
  643. i18n: 'unlink',
  644. handler: function handler(editor) {
  645. editor.execCommand('unlink');
  646. }
  647. };
  648. /**
  649. * build-in moduls
  650. * Created by peak on 2016/11/1.
  651. */
  652. var buildInModules = [
  653. text,
  654. color,
  655. font,
  656. align,
  657. list,
  658. link,
  659. unlink,
  660. table,
  661. image,
  662. hr,
  663. eraser,
  664. undo,
  665. fullScreen$1,
  666. info
  667. ];
  668. /**
  669. * Created by peak on 2017/2/15.
  670. */
  671. /**
  672. * add every elements of extArr to sourceArr.
  673. * @param sourceArr
  674. * @param extArr
  675. */
  676. var mergeArray = function (sourceArr, extArr) {
  677. // note: Array.prototype.push.apply(arr1,arr2) is unreliable
  678. extArr.forEach(function (el) {
  679. sourceArr.push(el);
  680. });
  681. };
  682. /**
  683. * find all the descendant text nodes of a element
  684. * @param ancestor
  685. */
  686. var getDescendantTextNodes = function (ancestor) {
  687. if (ancestor.nodeType === Node.TEXT_NODE) {
  688. return [ancestor]
  689. }
  690. var textNodes = [];
  691. if (!ancestor.hasChildNodes()) {
  692. return textNodes
  693. }
  694. var childNodes = ancestor.childNodes;
  695. for (var i = 0; i < childNodes.length; i++) {
  696. var node = childNodes[i];
  697. if (node.nodeType === Node.TEXT_NODE) {
  698. textNodes.push(node);
  699. } else if (node.nodeType === Node.ELEMENT_NODE) {
  700. mergeArray(textNodes, getDescendantTextNodes(node));
  701. }
  702. }
  703. return textNodes
  704. };
  705. /**
  706. * find all the descendant text nodes of an ancestor element that before the specify end element,
  707. * the ancestor element must contains the end element.
  708. * @param ancestor
  709. * @param endEl
  710. */
  711. var getBeforeEndDescendantTextNodes = function (ancestor, endEl) {
  712. var textNodes = [];
  713. var endIndex = 0;
  714. for (var i = 0; i < ancestor.childNodes.length; i++) {
  715. if (ancestor.childNodes[i].contains(endEl)) {
  716. endIndex = i;
  717. break
  718. }
  719. }
  720. for (var i$1 = 0; i$1 <= endIndex; i$1++) {
  721. var node = ancestor.childNodes[i$1];
  722. if (node === endEl) {
  723. mergeArray(textNodes, getDescendantTextNodes(node));
  724. } else if (i$1 === endIndex) {
  725. if (node.nodeType === Node.TEXT_NODE) {
  726. textNodes.push(node);
  727. } else if (node.nodeType === Node.ELEMENT_NODE) {
  728. mergeArray(textNodes, getBeforeEndDescendantTextNodes(node, endEl));
  729. }
  730. } else if (node.nodeType === Node.TEXT_NODE) {
  731. textNodes.push(node);
  732. } else if (node.nodeType === Node.ELEMENT_NODE) {
  733. mergeArray(textNodes, getDescendantTextNodes(node));
  734. }
  735. }
  736. return textNodes
  737. };
  738. /**
  739. * find all the descendant text nodes of an ancestor element that after the specify start element,
  740. * the ancestor element must contains the start element.
  741. * @param ancestor
  742. * @param startEl
  743. */
  744. var getAfterStartDescendantTextNodes = function (ancestor, startEl) {
  745. var textNodes = [];
  746. var startIndex = 0;
  747. for (var i = 0; i < ancestor.childNodes.length; i++) {
  748. if (ancestor.childNodes[i].contains(startEl)) {
  749. startIndex = i;
  750. break
  751. }
  752. }
  753. for (var i$1 = startIndex; i$1 < ancestor.childNodes.length; i$1++) {
  754. var node = ancestor.childNodes[i$1];
  755. if (node === startEl) {
  756. mergeArray(textNodes, getDescendantTextNodes(node));
  757. } else if (i$1 === startIndex) {
  758. if (node.nodeType === Node.TEXT_NODE) {
  759. textNodes.push(node);
  760. } else if (node.nodeType === Node.ELEMENT_NODE) {
  761. mergeArray(textNodes,
  762. getAfterStartDescendantTextNodes(node, startEl));
  763. }
  764. } else if (node.nodeType === Node.TEXT_NODE) {
  765. textNodes.push(node);
  766. } else if (node.nodeType === Node.ELEMENT_NODE) {
  767. mergeArray(textNodes,
  768. getDescendantTextNodes(node));
  769. }
  770. }
  771. return textNodes
  772. };
  773. /**
  774. * get the closest parent block node of a text node.
  775. * @param node
  776. * @return {Node}
  777. */
  778. var getParentBlockNode = function (node) {
  779. var blockNodeNames = ['DIV', 'P', 'SECTION', 'H1', 'H2', 'H3', 'H4', 'H5', 'H6',
  780. 'OL', 'UL', 'LI', 'TR', 'TD', 'TH', 'TBODY', 'THEAD', 'TABLE', 'ARTICLE', 'HEADER', 'FOOTER'];
  781. var container = node;
  782. while (container) {
  783. if (blockNodeNames.includes(container.nodeName)) {
  784. break
  785. }
  786. container = container.parentNode;
  787. }
  788. return container
  789. };
  790. var isInlineElement = function (node) {
  791. var inlineNodeNames = ['A', 'ABBR', 'ACRONYM', 'B', 'CITE', 'CODE', 'EM', 'I',
  792. 'FONT', 'IMG', 'S', 'SMALL', 'SPAN', 'STRIKE', 'STRONG', 'U', 'SUB', 'SUP'];
  793. return inlineNodeNames.includes(node.nodeName)
  794. };
  795. // for IE 11
  796. if (!Text.prototype.contains) {
  797. Text.prototype.contains = function contains(otherNode) {
  798. return this === otherNode
  799. };
  800. }
  801. /**
  802. * Created by peak on 2017/2/14.
  803. */
  804. var RangeHandler = function RangeHandler(range) {
  805. if (!range || !(range instanceof Range)) {
  806. throw new TypeError('cant\'t resolve range')
  807. }
  808. this.range = range;
  809. };
  810. /**
  811. * find all the text nodes in range
  812. */
  813. RangeHandler.prototype.getAllTextNodesInRange = function getAllTextNodesInRange () {
  814. var startContainer = this.range.startContainer;
  815. var endContainer = this.range.endContainer;
  816. var rootEl = this.range.commonAncestorContainer;
  817. var textNodes = [];
  818. if (startContainer === endContainer) {
  819. if (startContainer.nodeType === Node.TEXT_NODE) {
  820. return [startContainer]
  821. }
  822. var childNodes = startContainer.childNodes;
  823. for (var i = this.range.startOffset; i < this.range.endOffset; i++) {
  824. mergeArray(textNodes, getDescendantTextNodes(childNodes[i]));
  825. }
  826. return textNodes
  827. }
  828. var startIndex = 0;
  829. var endIndex = 0;
  830. for (var i$1 = 0; i$1 < rootEl.childNodes.length; i$1++) {
  831. var node = rootEl.childNodes[i$1];
  832. if (node.contains(startContainer)) {
  833. startIndex = i$1;
  834. }
  835. if (node.contains(endContainer)) {
  836. endIndex = i$1;
  837. }
  838. }
  839. for (var i$2 = startIndex; i$2 <= endIndex; i$2++) {
  840. var node$1 = rootEl.childNodes[i$2];
  841. if (i$2 === startIndex) {
  842. if (node$1.nodeType === Node.TEXT_NODE) {
  843. textNodes.push(node$1);
  844. } else if (node$1.nodeType === Node.ELEMENT_NODE) {
  845. mergeArray(textNodes, getAfterStartDescendantTextNodes(node$1, startContainer));
  846. }
  847. } else if (i$2 === endIndex) {
  848. if (node$1.nodeType === Node.TEXT_NODE) {
  849. textNodes.push(node$1);
  850. } else if (node$1.nodeType === Node.ELEMENT_NODE) {
  851. mergeArray(textNodes, getBeforeEndDescendantTextNodes(node$1, endContainer));
  852. }
  853. } else if (node$1.nodeType === Node.TEXT_NODE) {
  854. textNodes.push(node$1);
  855. } else if (node$1.nodeType === Node.ELEMENT_NODE) {
  856. mergeArray(textNodes, getDescendantTextNodes(node$1));
  857. }
  858. }
  859. return textNodes
  860. };
  861. /**
  862. * execute edit command
  863. * @param {String} command
  864. * @param arg
  865. */
  866. RangeHandler.prototype.execCommand = function execCommand (command, arg) {
  867. var this$1 = this;
  868. switch (command) {
  869. case Command.FONT_SIZE: {
  870. // 重新实现,改为直接修改样式
  871. var textNodes = this.getAllTextNodesInRange();
  872. if (!textNodes.length) {
  873. break
  874. }
  875. if (textNodes.length === 1 && textNodes[0] === this.range.startContainer
  876. && textNodes[0] === this.range.endContainer) {
  877. var textNode = textNodes[0];
  878. if (this.range.startOffset === 0
  879. && this.range.endOffset === textNode.textContent.length) {
  880. if (textNode.parentNode.childNodes.length === 1
  881. && isInlineElement(textNode.parentNode)) {
  882. textNode.parentNode.style.fontSize = arg;
  883. break
  884. }
  885. var span = document.createElement('span');
  886. span.style.fontSize = arg;
  887. textNode.parentNode.insertBefore(span, textNode);
  888. span.appendChild(textNode);
  889. break
  890. }
  891. var span$1 = document.createElement('span');
  892. span$1.innerText = textNode.textContent.substring(
  893. this.range.startOffset, this.range.endOffset);
  894. span$1.style.fontSize = arg;
  895. var frontPart = document.createTextNode(
  896. textNode.textContent.substring(0, this.range.startOffset));
  897. textNode.parentNode.insertBefore(frontPart, textNode);
  898. textNode.parentNode.insertBefore(span$1, textNode);
  899. textNode.textContent = textNode.textContent.substring(this.range.endOffset);
  900. this.range.setStart(span$1, 0);
  901. this.range.setEnd(span$1, 1);
  902. break
  903. }
  904. textNodes.forEach(function (textNode) {
  905. if (textNode === this$1.range.startContainer) {
  906. if (this$1.range.startOffset === 0) {
  907. if (textNode.parentNode.childNodes.length === 1
  908. && isInlineElement(textNode.parentNode)) {
  909. textNode.parentNode.style.fontSize = arg;
  910. } else {
  911. var span$1 = document.createElement('span');
  912. span$1.style.fontSize = arg;
  913. textNode.parentNode.insertBefore(span$1, textNode);
  914. span$1.appendChild(textNode);
  915. }
  916. return
  917. }
  918. var span$2 = document.createElement('span');
  919. textNode.textContent = textNode.textContent.substring(
  920. 0, this$1.range.startOffset);
  921. span$2.style.fontSize = arg;
  922. textNode.parentNode.insertBefore(span$2, textNode);
  923. this$1.range.setStart(textNode, 0);
  924. return
  925. }
  926. if (textNode === this$1.range.endContainer) {
  927. if (this$1.range.endOffset === textNode.textContent.length) {
  928. if (textNode.parentNode.childNodes.length === 1
  929. && isInlineElement(textNode.parentNode)) {
  930. textNode.parentNode.style.fontSize = arg;
  931. } else {
  932. var span$3 = document.createElement('span');
  933. span$3.style.fontSize = arg;
  934. textNode.parentNode.insertBefore(span$3, textNode);
  935. span$3.appendChild(textNode);
  936. }
  937. return
  938. }
  939. var span$4 = document.createElement('span');
  940. textNode.textContent = textNode.textContent.substring(this$1.range.endOffset);
  941. span$4.style.fontSize = arg;
  942. textNode.parentNode.insertBefore(span$4, textNode);
  943. span$4.appendChild(textNode);
  944. this$1.range.setStart(textNode, textNode.textContent.length);
  945. return
  946. }
  947. if (textNode.parentNode.childNodes.length === 1
  948. && isInlineElement(textNode.parentNode)) {
  949. textNode.parentNode.style.fontSize = arg;
  950. return
  951. }
  952. var span = document.createElement('span');
  953. span.style.fontSize = arg;
  954. textNode.parentNode.insertBefore(span, textNode);
  955. span.appendChild(textNode);
  956. });
  957. break
  958. }
  959. case Command.FORMAT_BLOCK: {
  960. if (document.execCommand(Command.FORMAT_BLOCK, false, arg)) {
  961. break
  962. }
  963. // hack
  964. var element = document.createElement(arg);
  965. this.range.surroundContents(element);
  966. break
  967. }
  968. case Command.LINE_HEIGHT: {
  969. var textNodes$1 = this.getAllTextNodesInRange();
  970. textNodes$1.forEach(function (textNode) {
  971. var parentBlock = getParentBlockNode(textNode);
  972. if (parentBlock) {
  973. parentBlock.style.lineHeight = arg;
  974. }
  975. });
  976. break
  977. }
  978. case Command.INSERT_HTML: {
  979. if (document.execCommand(Command.INSERT_HTML, false, arg)) {
  980. break
  981. }
  982. // hack
  983. var fragment = document.createDocumentFragment();
  984. var div = document.createElement('div');
  985. div.innerHTML = arg;
  986. if (div.hasChildNodes()) {
  987. for (var i = 0; i < div.childNodes.length; i++) {
  988. fragment.appendChild(div.childNodes[i].cloneNode(true));
  989. }
  990. }
  991. this.range.deleteContents();
  992. this.range.insertNode(fragment);
  993. break
  994. }
  995. default: {
  996. document.execCommand(command, false, arg);
  997. break
  998. }
  999. }
  1000. };
  1001. __$styleInject(".vue-html5-editor,.vue-html5-editor *{box-sizing:border-box}.vue-html5-editor{font-size:14px;line-height:1.5;background-color:#fff;color:#333;border:1px solid #ddd;text-align:left;border-radius:5px;overflow:hidden}.vue-html5-editor.full-screen{position:fixed!important;top:0!important;left:0!important;bottom:0!important;right:0!important;border-radius:0}.vue-html5-editor>.toolbar{position:relative;background-color:inherit}.vue-html5-editor>.toolbar>ul{list-style:none;padding:0;margin:0;border-bottom:1px solid #ddd}.vue-html5-editor>.toolbar>ul>li{display:inline-block;cursor:pointer;text-align:center;line-height:36px;padding:0 10px}.vue-html5-editor>.toolbar>ul>li .icon{height:16px;width:16px;display:inline-block;vertical-align:middle}.vue-html5-editor>.toolbar>.dashboard{background-color:inherit;border-bottom:1px solid #ddd;padding:10px;position:absolute;top:100%;left:0;right:0;overflow:auto}.vue-html5-editor>.toolbar>.dashboard input[type=text],.vue-html5-editor>.toolbar>.dashboard input[type=number],.vue-html5-editor>.toolbar>.dashboard select{padding:6px 12px;color:inherit;background-color:transparent;border:1px solid #ddd;border-radius:5px}.vue-html5-editor>.toolbar>.dashboard input[type=text]:hover,.vue-html5-editor>.toolbar>.dashboard input[type=number]:hover,.vue-html5-editor>.toolbar>.dashboard select:hover{border-color:#bebebe}.vue-html5-editor>.toolbar>.dashboard input[type=text][disabled],.vue-html5-editor>.toolbar>.dashboard input[type=text][readonly],.vue-html5-editor>.toolbar>.dashboard input[type=number][disabled],.vue-html5-editor>.toolbar>.dashboard input[type=number][readonly],.vue-html5-editor>.toolbar>.dashboard select[disabled],.vue-html5-editor>.toolbar>.dashboard select[readonly]{background-color:#eee;opacity:1}.vue-html5-editor>.toolbar>.dashboard input[type=text][disabled],.vue-html5-editor>.toolbar>.dashboard input[type=number][disabled],.vue-html5-editor>.toolbar>.dashboard select[disabled]{cursor:not-allowed}.vue-html5-editor>.toolbar>.dashboard button{color:inherit;background-color:inherit;padding:6px 12px;white-space:nowrap;vertical-align:middle;cursor:pointer;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;border:1px solid #ddd;border-radius:5px;margin-right:4px;margin-bottom:4px}.vue-html5-editor>.toolbar>.dashboard button:hover{border-color:#bebebe}.vue-html5-editor>.toolbar>.dashboard button[disabled]{cursor:not-allowed;opacity:.68}.vue-html5-editor>.toolbar>.dashboard button:last-child{margin-right:0}.vue-html5-editor>.toolbar>.dashboard label{font-weight:bolder}.vue-html5-editor>.content{overflow:auto;padding:10px}.vue-html5-editor>.content:focus{outline:0}",undefined);
  1002. var template$9 = "<div class=\"vue-html5-editor\" :class=\"{'full-screen':fullScreen}\" :style=\"{'z-index':zIndex}\"> <div class=\"toolbar\" :style=\"{'z-index':zIndex+1}\" ref=\"toolbar\"> <ul> <template v-for=\"module in modules\"> <li :title=\"locale[module.i18n]\" @click=\"activeModule(module)\"> <span class=\"icon\" :class=\"module.icon\"></span> <template v-if=\"showModuleName === undefined ? defaultShowModuleName : showModuleName\"> &nbsp;{{locale[module.i18n]}} </template> </li> </template> </ul> <div class=\"dashboard\" v-show=\"dashboard\" ref=\"dashboard\"> <keep-alive> <div v-show=\"dashboard\" :is=\"dashboard\"></div> </keep-alive> </div> </div> <div class=\"content\" ref=\"content\" :style=\"contentStyle\" contenteditable @click=\"toggleDashboard(dashboard)\"> </div> </div>";
  1003. /**
  1004. * Created by peak on 2017/2/9.
  1005. */
  1006. var editor = {
  1007. template: template$9,
  1008. props: {
  1009. content: {
  1010. type: String,
  1011. required: true,
  1012. default: ''
  1013. },
  1014. height: {
  1015. type: Number,
  1016. default: 300,
  1017. validator: function validator(val){
  1018. return val >= 100
  1019. }
  1020. },
  1021. zIndex: {
  1022. type: Number,
  1023. default: 1000
  1024. },
  1025. autoHeight: {
  1026. type: Boolean,
  1027. default: true
  1028. },
  1029. showModuleName: {}
  1030. },
  1031. data: function data(){
  1032. return {
  1033. // defaultShowModuleName:false
  1034. // locale: {},
  1035. // modules:{},
  1036. fullScreen: false,
  1037. dashboard: null
  1038. }
  1039. },
  1040. watch: {
  1041. content: function content(val) {
  1042. var content = this.$refs.content.innerHTML;
  1043. if (val !== content) {
  1044. this.$refs.content.innerHTML = val;
  1045. }
  1046. },
  1047. fullScreen: function fullScreen(val){
  1048. var component = this;
  1049. if (val) {
  1050. component.parentEl = component.$el.parentNode;
  1051. component.nextEl = component.$el.nextSibling;
  1052. document.body.appendChild(component.$el);
  1053. return
  1054. }
  1055. if (component.nextEl) {
  1056. component.parentEl.insertBefore(component.$el, component.nextEl);
  1057. return
  1058. }
  1059. component.parentEl.appendChild(component.$el);
  1060. }
  1061. },
  1062. computed: {
  1063. contentStyle: function contentStyle(){
  1064. var style = {};
  1065. if (this.fullScreen) {
  1066. style.height = (window.innerHeight - this.$refs.toolbar.clientHeight - 1) + "px";
  1067. return style
  1068. }
  1069. if (!this.autoHeight) {
  1070. style.height = (this.height) + "px";
  1071. return style
  1072. }
  1073. style['min-height'] = (this.height) + "px";
  1074. return style
  1075. }
  1076. },
  1077. methods: {
  1078. toggleFullScreen: function toggleFullScreen(){
  1079. this.fullScreen = !this.fullScreen;
  1080. },
  1081. enableFullScreen: function enableFullScreen(){
  1082. this.fullScreen = true;
  1083. },
  1084. exitFullScreen: function exitFullScreen(){
  1085. this.fullScreen = false;
  1086. },
  1087. focus: function focus(){
  1088. this.$refs.content.focus();
  1089. },
  1090. toggleDashboard: function toggleDashboard(dashboard){
  1091. this.dashboard = this.dashboard === dashboard ? null : dashboard;
  1092. },
  1093. execCommand: function execCommand(command, arg){
  1094. this.restoreSelection();
  1095. if (this.range) {
  1096. new RangeHandler(this.range).execCommand(command, arg);
  1097. }
  1098. this.toggleDashboard();
  1099. this.$emit('change', this.$refs.content.innerHTML);
  1100. },
  1101. getCurrentRange: function getCurrentRange(){
  1102. return this.range
  1103. },
  1104. saveCurrentRange: function saveCurrentRange(){
  1105. var this$1 = this;
  1106. var selection = window.getSelection ? window.getSelection() : document.getSelection();
  1107. if (!selection.rangeCount) {
  1108. return
  1109. }
  1110. var content = this.$refs.content;
  1111. for (var i = 0; i < selection.rangeCount; i++) {
  1112. var range = selection.getRangeAt(0);
  1113. var start = range.startContainer;
  1114. var end = range.endContainer;
  1115. // for IE11 : node.contains(textNode) always return false
  1116. start = start.nodeType === Node.TEXT_NODE ? start.parentNode : start;
  1117. end = end.nodeType === Node.TEXT_NODE ? end.parentNode : end;
  1118. if (content.contains(start) && content.contains(end)) {
  1119. this$1.range = range;
  1120. break
  1121. }
  1122. }
  1123. },
  1124. restoreSelection: function restoreSelection(){
  1125. var selection = window.getSelection ? window.getSelection() : document.getSelection();
  1126. selection.removeAllRanges();
  1127. if (this.range) {
  1128. selection.addRange(this.range);
  1129. } else {
  1130. var content = this.$refs.content;
  1131. var div = document.createElement('div');
  1132. var range = document.createRange();
  1133. content.appendChild(div);
  1134. range.setStart(div, 0);
  1135. range.setEnd(div, 0);
  1136. selection.addRange(range);
  1137. this.range = range;
  1138. }
  1139. },
  1140. activeModule: function activeModule(module){
  1141. if (typeof module.handler === 'function') {
  1142. module.handler(this);
  1143. return
  1144. }
  1145. if (module.hasDashboard) {
  1146. this.toggleDashboard(("dashboard-" + (module.name)));
  1147. }
  1148. }
  1149. },
  1150. created: function created(){
  1151. var this$1 = this;
  1152. this.modules.forEach(function (module) {
  1153. if (typeof module.init === 'function') {
  1154. module.init(this$1);
  1155. }
  1156. });
  1157. },
  1158. mounted: function mounted(){
  1159. var this$1 = this;
  1160. var content = this.$refs.content;
  1161. content.innerHTML = this.content;
  1162. content.addEventListener('mouseup', this.saveCurrentRange, false);
  1163. content.addEventListener('keyup', function () {
  1164. this$1.$emit('change', content.innerHTML);
  1165. this$1.saveCurrentRange();
  1166. }, false);
  1167. content.addEventListener('mouseout', function (e) {
  1168. if (e.target === content) {
  1169. this$1.saveCurrentRange();
  1170. }
  1171. }, false);
  1172. this.touchHandler = function (e) {
  1173. if (content.contains(e.target)) {
  1174. this$1.saveCurrentRange();
  1175. }
  1176. };
  1177. window.addEventListener('touchend', this.touchHandler, false);
  1178. },
  1179. updated: function updated(){
  1180. // update dashboard style
  1181. if (this.$refs.dashboard){
  1182. this.$refs.dashboard.style.maxHeight = (this.$refs.content.clientHeight) + "px";
  1183. }
  1184. },
  1185. beforeDestroy: function beforeDestroy(){
  1186. var this$1 = this;
  1187. window.removeEventListener('touchend', this.touchHandler);
  1188. this.modules.forEach(function (module) {
  1189. if (typeof module.destroyed === 'function') {
  1190. module.destroyed(this$1);
  1191. }
  1192. });
  1193. }
  1194. };
  1195. var i18nZhCn = {
  1196. align: '对齐方式',
  1197. image: '图片',
  1198. list: '列表',
  1199. link: '链接',
  1200. unlink: '去除链接',
  1201. table: '表格',
  1202. font: '文字',
  1203. 'full screen': '全屏',
  1204. text: '排版',
  1205. eraser: '格式清除',
  1206. info: '关于',
  1207. color: '颜色',
  1208. 'please enter a url': '请输入地址',
  1209. 'create link': '创建链接',
  1210. bold: '加粗',
  1211. italic: '倾斜',
  1212. underline: '下划线',
  1213. 'strike through': '删除线',
  1214. subscript: '上标',
  1215. superscript: '下标',
  1216. heading: '标题',
  1217. 'font name': '字体',
  1218. 'font size': '文字大小',
  1219. 'left justify': '左对齐',
  1220. 'center justify': '居中',
  1221. 'right justify': '右对齐',
  1222. 'ordered list': '有序列表',
  1223. 'unordered list': '无序列表',
  1224. 'fore color': '前景色',
  1225. 'background color': '背景色',
  1226. 'row count': '行数',
  1227. 'column count': '列数',
  1228. save: '确定',
  1229. upload: '上传',
  1230. progress: '进度',
  1231. unknown: '未知',
  1232. 'please wait': '请稍等',
  1233. error: '错误',
  1234. abort: '中断',
  1235. reset: '重置',
  1236. hr: '分隔线',
  1237. undo: '撤消',
  1238. 'line height': '行高',
  1239. 'exceed size limit': '超出大小限制'
  1240. };
  1241. var i18nEnUs = {
  1242. align: 'align',
  1243. image: 'image',
  1244. list: 'list',
  1245. link: 'link',
  1246. unlink: 'unlink',
  1247. table: 'table',
  1248. font: 'font',
  1249. 'full screen': 'full screen',
  1250. text: 'text',
  1251. eraser: 'remove format',
  1252. info: 'info',
  1253. color: 'color',
  1254. 'please enter a url': 'please enter a url',
  1255. 'create link': 'create link',
  1256. bold: 'bold',
  1257. italic: 'italic',
  1258. underline: 'underline',
  1259. 'strike through': 'strike through',
  1260. subscript: 'subscript',
  1261. superscript: 'superscript',
  1262. heading: 'heading',
  1263. 'font name': 'font name',
  1264. 'font size': 'font size',
  1265. 'left justify': 'left justify',
  1266. 'center justify': 'center justify',
  1267. 'right justify': 'right justify',
  1268. 'ordered list': 'ordered list',
  1269. 'unordered list': 'unordered list',
  1270. 'fore color': 'fore color',
  1271. 'background color': 'background color',
  1272. 'row count': 'row count',
  1273. 'column count': 'column count',
  1274. save: 'save',
  1275. upload: 'upload',
  1276. progress: 'progress',
  1277. unknown: 'unknown',
  1278. 'please wait': 'please wait',
  1279. error: 'error',
  1280. abort: 'abort',
  1281. reset: 'reset',
  1282. hr: 'horizontal rule',
  1283. undo: 'undo',
  1284. 'line height': 'line height',
  1285. 'exceed size limit': 'exceed size limit'
  1286. };
  1287. /**
  1288. * Created by peak on 2017/2/24.
  1289. */
  1290. /**
  1291. * shadow clone
  1292. *
  1293. * @param source source object
  1294. * @param ext extended object
  1295. */
  1296. function mixin(source, ext) {
  1297. if ( source === void 0 ) source = {};
  1298. if ( ext === void 0 ) ext = {};
  1299. Object.keys(ext).forEach(function (k) {
  1300. // for data function
  1301. if (k === 'data') {
  1302. var dataSrc = source[k];
  1303. var dataDesc = ext[k];
  1304. if (typeof dataDesc === 'function') {
  1305. if (typeof dataSrc !== 'function') {
  1306. source[k] = dataDesc;
  1307. } else {
  1308. source[k] = function () { return mixin(dataSrc(), dataDesc()); };
  1309. }
  1310. }
  1311. } else {
  1312. source[k] = ext[k];
  1313. }
  1314. });
  1315. return source
  1316. }
  1317. polyfill();
  1318. /**
  1319. * Vue html5 Editor
  1320. * @param Vue {Vue}
  1321. * @param options {Object}
  1322. */
  1323. var VueHtml5Editor = function VueHtml5Editor(options) {
  1324. if ( options === void 0 ) options = {};
  1325. var modules = [].concat( buildInModules );
  1326. var components = {};
  1327. // extended modules
  1328. if (Array.isArray(options.modules)) {
  1329. options.modules.forEach(function (module) {
  1330. if (module.name) {
  1331. modules.push(module);
  1332. }
  1333. });
  1334. }
  1335. // hidden modules
  1336. if (Array.isArray(options.hiddenModules)) {
  1337. modules = (function () {
  1338. var arr = [];
  1339. modules.forEach(function (m) {
  1340. if (!options.hiddenModules.includes(m.name)) {
  1341. arr.push(m);
  1342. }
  1343. });
  1344. return arr
  1345. })();
  1346. }
  1347. // visible modules
  1348. if (Array.isArray(options.visibleModules)) {
  1349. modules = (function () {
  1350. var arr = [];
  1351. options.visibleModules.forEach(function (name) {
  1352. modules.forEach(function (module) {
  1353. if (module.name === name) {
  1354. arr.push(module);
  1355. }
  1356. });
  1357. });
  1358. return arr
  1359. })();
  1360. }
  1361. modules.forEach(function (module) {
  1362. // specify the config for each module in options by name
  1363. var config = options[module.name];
  1364. module.config = mixin(module.config, config);
  1365. if (module.dashboard) {
  1366. // $options.module
  1367. module.dashboard.module = module;
  1368. components[("dashboard-" + (module.name))] = module.dashboard;
  1369. }
  1370. if (options.icons && options.icons[module.name]) {
  1371. module.icon = options.icons[module.name];
  1372. }
  1373. module.hasDashboard = !!module.dashboard;
  1374. // prevent vue sync
  1375. module.dashboard = null;
  1376. });
  1377. // i18n
  1378. var i18n = {'zh-cn': i18nZhCn, 'en-us': i18nEnUs};
  1379. var customI18n = options.i18n || {};
  1380. Object.keys(customI18n).forEach(function (key) {
  1381. i18n[key] = i18n[key] ? mixin(i18n[key], customI18n[key]) : customI18n[key];
  1382. });
  1383. var language = options.language || 'en-us';
  1384. var locale = i18n[language];
  1385. // showModuleName
  1386. var defaultShowModuleName = !!options.showModuleName;
  1387. // ######################################
  1388. var compo = mixin(editor, {
  1389. data: function data() {
  1390. return {modules: modules, locale: locale, defaultShowModuleName: defaultShowModuleName}
  1391. },
  1392. components: components
  1393. });
  1394. mixin(this, compo);
  1395. };
  1396. /**
  1397. * global install
  1398. *
  1399. * @param Vue
  1400. * @param options
  1401. */
  1402. VueHtml5Editor.install = function install (Vue, options) {
  1403. if ( options === void 0 ) options = {};
  1404. Vue.component(options.name || 'vue-html5-editor', new VueHtml5Editor(options));
  1405. };
  1406. return VueHtml5Editor;
  1407. })));