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

13 lines
53 KiB
JavaScript
Raw Normal View History

var t="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function createCommonjsModule(t,e,n){return t(n={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&&n.path)}},n.exports),n.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")(),fails=function(t){try{return!!t()}catch(t){return!0}},n=!fails((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),r={}.propertyIsEnumerable,o=Object.getOwnPropertyDescriptor,i={f:o&&!r.call({1:2},1)?function propertyIsEnumerable(t){var e=o(this,t);return!!e&&e.enumerable}:r},createPropertyDescriptor=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},c={}.toString,classofRaw=function(t){return c.call(t).slice(8,-1)},a="".split,u=fails((function(){return!Object("z").propertyIsEnumerable(0)}))?function(t){return"String"==classofRaw(t)?a.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 n,r;if(e&&"function"==typeof(n=t.toString)&&!isObject(r=n.call(t)))return r;if("function"==typeof(n=t.valueOf)&&!isObject(r=n.call(t)))return r;if(!e&&"function"==typeof(n=t.toString)&&!isObject(r=n.call(t)))return r;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=!n&&!fails((function(){return 7!=Object.defineProperty(documentCreateElement("div"),"a",{get:function(){return 7}}).a})),h=Object.getOwnPropertyDescriptor,d={f:n?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},v=Object.defineProperty,g={f:n?v:function defineProperty(t,e,n){if(anObject(t),e=toPrimitive(e,!0),anObject(n),p)try{return v(t,e,n)}catch(t){}if("get"in n||"set"in n)throw TypeError("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},y=n?function(t,e,n){return g.f(t,e,createPropertyDescriptor(1,n))}:function(t,e,n){return t[e]=n,t},setGlobal=function(t,n){try{y(e,t,n)}catch(r){e[t]=n}return n},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 x,S,w,E=m.inspectSource,_=e.WeakMap,O="function"==typeof _&&/native code/.test(E(_)),j=createCommonjsModule((function(t){(t.exports=function(t,e){return m[t]||(m[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.6.5",mode:"global",copyright:"© 2020 Denis Pushkarev (zloirock.ru)"})})),A=0,P=Math.random(),uid=function(t){return"Symbol("+String(void 0===t?"":t)+")_"+(++A+P).toString(36)},T=j("keys"),sharedKey=function(t){return T[t]||(T[t]=uid(t))},k={},I=e.WeakMap;if(O){var L=new I,R=L.get,C=L.has,M=L.set;x=function(t,e){return M.call(L,t,e),e},S=function(t){return R.call(L,t)||{}},w=function(t){return C.call(L,t)}}else{var N=sharedKey("state");k[N]=!0,x=function(t,e){return y(t,N,e),e},S=function(t){return has(t,N)?t[N]:{}},w=function(t){return has(t,N)}}var G,D,z={set:x,get:S,has:w,enforce:function(t){return w(t)?S(t):x(t,{})},getterFor:function(t){return function(e){var n;if(!isObject(e)||(n=S(e)).type!==t)throw TypeError("Incompatible receiver, "+t+" required");return n}}},U=createCommonjsModule((function(t){var n=z.get,r=z.enforc
2020-09-06 06:32:10 +00:00
/**
* Localizing script for SVG-edit UI.
* @module locale
* @license MIT
2020-09-06 06:32:10 +00:00
*
* @copyright 2010 Narendra Sisodya
* @copyright 2010 Alexis Deveria
2020-09-06 06:32:10 +00:00
*
*/
jQuery;var zo=function(){var t=_asyncToGenerator(regeneratorRuntime.mark((function _callee2(t,e){var n;return regeneratorRuntime.wrap((function _callee2$(r){for(;;)switch(r.prev=r.next){case 0:return r.prev=0,r.next=3,import("./extensions/ext-".concat(t,"/locale/").concat(e,".js"));case 3:n=r.sent,r.next=12;break;case 6:return r.prev=6,r.t0=r.catch(0),console.error("Missing translation (".concat(e,") for extension ").concat(t," - using 'en'")),r.next=11,import("./extensions/ext-".concat(t,"/locale/en.js"));case 11:n=r.sent;case 12:return r.abrupt("return",n.default);case 13:case"end":return r.stop()}}),_callee2,null,[[0,6]])})));return function loadExtensionTranslation(e,n){return t.apply(this,arguments)}}(),Uo={name:"foreignobject",init:function init(t){var e=this;return _asyncToGenerator(regeneratorRuntime.mark((function _callee2(){var n,r,o,i,c,a,u,f,s,l,p,h,d,v,g,y,m,b,x;return regeneratorRuntime.wrap((function _callee2$(S){for(;;)switch(S.prev=S.next){case 0:return m=function _setAttr(t,e){c.changeSelectedAttribute(t,e),c.call("changed",p)},y=function _showForeignEditor(){var t=p[0];if(t&&!v){v=!0,l(!0),t.removeAttribute("fill");var e=c.svgToString(t,0);r("#svg_source_textarea").val(e),r("#svg_source_editor").fadeIn(),f(),r("#svg_source_textarea").focus()}},g=function _setForeignString(t){var e=p[0];try{var n=o('<svg xmlns="'+i.SVG+'" xmlns:xlink="'+i.XLINK+'">'+t+"</svg>");c.sanitizeSvg(n.documentElement),e.replaceWith(a.importNode(n.documentElement.firstChild,!0)),c.call("changed",[e]),c.clearSelection()}catch(t){return console.log(t),!1}return!0},l=function _toggleSourceButtons(t){r("#tool_source_save, #tool_source_cancel").toggle(!t),r("#foreign_save, #foreign_cancel").toggle(t)},s=function _showPanel(t){var e=r("#fc_rules");e.length||(e=r('<style id="fc_rules"></style>').appendTo("head")),e.text(t?" #tool_topath { display: none !important; }":""),r("#foreignObject_panel").toggle(t)},n=e,r=t.$,o=t.text2xml,i=t.NS,c=n.canvas,a=t.svgroot.parentNode.ownerDocument,S.next=11,zo("foreignobject",n.curPrefs.lang);case 11:return u=S.sent,f=function properlySourceSizeTextArea(){var t=r("#svg_source_container").height()-80;r("#svg_source_textarea").css("height",t)},v=!1,b=[{id:"tool_foreign",icon:"foreignobject-tool.png",type:"mode",events:{click:function click(){c.setMode("foreign")}}},{id:"edit_foreign",icon:"foreignobject-edit.png",type:"context",panel:"foreignObject_panel",events:{click:function click(){y()}}}],x=[{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(x[e],t)})),callback:function callback(){r("#foreignObject_panel").hide();var t=function endChanges(){r("#svg_source_editor").hide(),v=!1,r("#svg_source_textarea").blur(),l(!1)};setTimeout((function(){r("#tool_source_save").clone().hide().attr("id","foreign_save").unbind().appendTo("#tool_source_back").click(_asyncToGenerator(regeneratorRuntime.mark((function _callee(){return regeneratorRuntime.wrap((function _callee$(e){for(;;)switch(e.prev=e.next){case 0:if(v){e.next=2;break}return e.abrupt("return");case 2:if(g(r("#svg_source_textarea").val())){e.next=11;break}return e.next=5,r.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()}}),_callee)})))),r("#tool_source_cancel").clone().hide().attr("id","foreign_cancel").unbind().appendTo("#tool_source_back").click((function(){t()}))}),3e3)},mouseDown:function mouseDown(t){if("foreign"===c.getMode()){h=!0,d=c.addSVGElementFromJson({element:"foreignObject",at
2020-09-06 06:32:10 +00:00
//# sourceMappingURL=ext-foreignobject.js.map