svgedit/dist/editor/extensions/ext-foreignobject/ext-foreignobject.js

11 lines
46 KiB
JavaScript
Raw Normal View History

2020-11-12 20:14:36 +00:00
var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,r){return t(r={path:e,exports:{},require:function(t,e){return function commonjsRequire(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}(null==e&&r.path)}},r.exports),r.exports}var check=function(t){return t&&t.Math==Math&&t},e=check("object"==typeof globalThis&&globalThis)||check("object"==typeof window&&window)||check("object"==typeof self&&self)||check("object"==typeof t&&t)||function(){return this}()||Function("return this")(),fails=function(t){try{return!!t()}catch(t){return!0}},r=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),n={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!n.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:n},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},a={}.toString,classofRaw=function(t){return a.call(t).slice(8,-1)},c="".split,u=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?c.call(t,""):Object(t)}:Object,requireObjectCoercible=function(t){if(null==t)throw TypeError("Can't call method on "+t);return t},toIndexedObject=function(t){return u(requireObjectCoercible(t))},isObject=function(t){return"object"==typeof t?null!==t:"function"==typeof t},toPrimitive=function(t,e){if(!isObject(t))return t;var r,n;if(e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;if("function"==typeof(r=t.valueOf)&&!isObject(n=r.call(t)))return n;if(!e&&"function"==typeof(r=t.toString)&&!isObject(n=r.call(t)))return n;throw TypeError("Can't convert object to primitive value")},f={}.hasOwnProperty,has=function(t,e){return f.call(t,e)},s=e.document,l=isObject(s)&&isObject(s.createElement),documentCreateElement=function(t){return l?s.createElement(t):{}},p=!r&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,v={f:r?h:function getOwnPropertyDescriptor(t,e){if(t=toIndexedObject(t),e=toPrimitive(e,!0),p)try{return h(t,e)}catch(t){}if(has(t,e))return createPropertyDescriptor(!i.f.call(t,e),t[e])}},anObject=function(t){if(!isObject(t))throw TypeError(String(t)+" is not an object");return t},y=Object.defineProperty,d={f:r?y:function defineProperty(t,e,r){if(anObject(t),e=toPrimitive(e,!0),anObject(r),p)try{return y(t,e,r)}catch(t){}if("get"in r||"set"in r)throw TypeError("Accessors not supported");return"value"in r&&(t[e]=r.value),t}},g=r?function(t,e,r){return d.f(t,e,createPropertyDescriptor(1,r))}:function(t,e,r){return t[e]=r,t},setGlobal=function(t,r){try{g(e,t,r)}catch(n){e[t]=r}return r},m=e["__core-js_shared__"]||setGlobal("__core-js_shared__",{}),b=Function.toString;"function"!=typeof m.inspectSource&&(m.inspectSource=function(t){return b.call(t)});var w,S,_,O=m.inspectSource,j=e.WeakMap,x="function"==typeof j&&/native code/.test(O(j)),E=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.7.0",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),P=0,T=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++P+T).toString(36)},A=E("keys"),sharedKey=function(t){return A[t]||(A[t]=uid(t))},k={},L=e.WeakMap;if(x){var I=m.state||(m.state=new L),C=I.get,M=I.has,N=I.set;w=function(t,e){return e.facade=t,N.call(I,t,e),e},S=function(t){return C.call(I,t)||{}},_=function(t){return M.call(I,t)}}else{var G=sharedKey("state");k[G]=!0,w=function(t,e){return e.facade=t,g(t,G,e),e},S=function(t){return has(t,G)?t[G]:{}},_=function(t){return has(t,G)}}var R,D,z={set:w,get:S,has:_,enforce:function(t){return _(t)?S(t):w(t,{})},getterFor:function(t){return function(e){var r;if(!isObject(e)||(r=S(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");re
2020-09-06 06:32:10 +00:00
/**
2020-09-11 23:27:47 +00:00
* @file ext-foreignobject.js
2020-09-06 06:32:10 +00:00
*
2020-09-11 23:27:47 +00:00
* @license Apache-2.0
2020-09-06 06:32:10 +00:00
*
2020-09-11 23:27:47 +00:00
* @copyright 2010 Jacques Distler, 2010 Alexis Deveria
*
2020-11-12 20:14:36 +00:00
*/var Bn=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee(t){var e;return regeneratorRuntime.wrap((function _callee$(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,__variableDynamicImportRuntime0__("./locale/".concat(encodeURIComponent(t),".js"));case 3:e=r.sent,r.next=12;break;case 6:return r.prev=6,r.t0=r.catch(0),console.error("Missing translation (".concat(t,") - using 'en'")),r.next=11,Promise.resolve().then((function(){return $n}));case 11:e=r.sent;case 12:return r.abrupt("return",e.default);case 13:case"end":return r.stop()}}),_callee,null,[[0,6]])})));return function loadExtensionTranslation(e){return t.apply(this,arguments)}}(),Yn={name:"foreignobject",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee3(){var r,n,o,i,a,c,u,f,s,l,p,h,v,y,d,g,m,b,w;return regeneratorRuntime.wrap((function _callee3$(S){for(;;)switch(S.prev=S.next){case 0:return m=function _setAttr(t,e){a.changeSelectedAttribute(t,e),a.call("changed",p)},g=function _showForeignEditor(){var t=p[0];if(t&&!y){y=!0,l(!0),t.removeAttribute("fill");var e=a.svgToString(t,0);n("#svg_source_textarea").val(e),n("#svg_source_editor").fadeIn(),f(),n("#svg_source_textarea").focus()}},d=function _setForeignString(t){var e=p[0];try{var r=o('<svg xmlns="'+i.SVG+'" xmlns:xlink="'+i.XLINK+'">'+t+"</svg>");a.sanitizeSvg(r.documentElement),e.replaceWith(c.importNode(r.documentElement.firstChild,!0)),a.call("changed",[e]),a.clearSelection()}catch(t){return console.log(t),!1}return!0},l=function _toggleSourceButtons(t){n("#tool_source_save, #tool_source_cancel").toggle(!t),n("#foreign_save, #foreign_cancel").toggle(t)},s=function _showPanel(t){var e=n("#fc_rules");e.length||(e=n('<style id="fc_rules"></style>').appendTo("head")),e.text(t?" #tool_topath { display: none !important; }":""),n("#foreignObject_panel").toggle(t)},r=e,n=t.$,o=t.text2xml,i=t.NS,a=r.canvas,c=t.svgroot.parentNode.ownerDocument,S.next=11,Bn(r.curPrefs.lang);case 11:return u=S.sent,f=function properlySourceSizeTextArea(){var t=n("#svg_source_container").height()-80;n("#svg_source_textarea").css("height",t)},y=!1,b=[{id:"tool_foreign",icon:"foreignobject-tool.png",type:"mode",events:{click:function click(){a.setMode("foreign")}}},{id:"edit_foreign",icon:"foreignobject-edit.png",type:"context",panel:"foreignObject_panel",events:{click:function click(){g()}}}],w=[{type:"input",panel:"foreignObject_panel",id:"foreign_width",size:3,events:{change:function change(){m("width",this.value)}}},{type:"input",panel:"foreignObject_panel",id:"foreign_height",events:{change:function change(){m("height",this.value)}}},{type:"input",panel:"foreignObject_panel",id:"foreign_font_size",size:2,defval:16,events:{change:function change(){m("font-size",this.value)}}}],S.abrupt("return",{name:u.name,svgicons:"foreignobject-icons.xml",buttons:u.buttons.map((function(t,e){return Object.assign(b[e],t)})),context_tools:u.contextTools.map((function(t,e){return Object.assign(w[e],t)})),callback:function callback(){n("#foreignObject_panel").hide();var t=function endChanges(){n("#svg_source_editor").hide(),y=!1,n("#svg_source_textarea").blur(),l(!1)};setTimeout((function(){n("#tool_source_save").clone().hide().attr("id","foreign_save").unbind().appendTo("#tool_source_back").click(_asyncToGenerator(regeneratorRuntime.mark((function _callee2(){return regeneratorRuntime.wrap((function _callee2$(e){for(;;)switch(e.prev=e.next){case 0:if(y){e.next=2;break}return e.abrupt("return");case 2:if(d(n("#svg_source_textarea").val())){e.next=11;break}return e.next=5,n.confirm("Errors found. Revert to original?");case 5:if(e.sent){e.next=8;break}return e.abrupt("return");case 8:t(),e.next=12;break;case 11:t();case 12:case"end":return e.stop()}}),_callee2)})))),n("#tool_source_cancel").clone().hide().attr("id","foreign_cancel").unbind().appendTo("#tool_source_back").click((function(){t()}))}),3e3)},mouseDown:function mouseDown(t){if("foreign"===a.getMode()){h=!0,v=a.addSVGElementFromJson({element:"foreignObject",attr:{x:t.start_x,y:t.start_y,id:a.getNext
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-foreignobject.js.map