@antv/g-plugin-html-renderer
Advanced tools
Comparing version 2.1.9 to 2.1.10
/*! | ||
* @antv/g-plugin-html-renderer | ||
* @description A G plugin for rendering HTML | ||
* @version 2.1.9 | ||
* @date 11/15/2024, 6:17:58 AM | ||
* @version 2.1.10 | ||
* @date 11/25/2024, 6:14:02 AM | ||
* @author AntVis | ||
@@ -7,0 +7,0 @@ * @docs https://g.antv.antgroup.com/ |
/*! | ||
* @antv/g-plugin-html-renderer | ||
* @description A G plugin for rendering HTML | ||
* @version 2.1.9 | ||
* @date 11/15/2024, 6:17:58 AM | ||
* @version 2.1.10 | ||
* @date 11/25/2024, 6:14:02 AM | ||
* @author AntVis | ||
@@ -7,0 +7,0 @@ * @docs https://g.antv.antgroup.com/ |
/*! | ||
* @antv/g-plugin-html-renderer | ||
* @description A G plugin for rendering HTML | ||
* @version 2.1.9 | ||
* @date 11/15/2024, 6:17:58 AM | ||
* @version 2.1.10 | ||
* @date 11/25/2024, 6:14:02 AM | ||
* @author AntVis | ||
* @docs https://g.antv.antgroup.com/ | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.HTMLRenderer={}),e.window.G)}(this,(function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function a(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function i(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}var f=function(e){return null==e},d={}.toString,y=function(e,t){return d.call(e)==="[object "+t+"]"},p=function(e){return y(e,"Number")},v=function(){function e(){r(this,e),this.displayObjectHTMLElementMap=new WeakMap}return i(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(r,n){var a=this,o=r.camera,i=r.renderingContext,s=r.renderingService;this.context=r;var l=i.root.ownerDocument.defaultView,c=l.context.eventService.nativeHTMLMap,u=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(o));var n=a.getOrCreateEl(r);a.$camera.appendChild(n),Object.keys(r.attributes).forEach((function(e){a.updateAttribute(e,r)})),u(r,n),c.set(n,r)}},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&a.$camera){var n=a.getOrCreateEl(r);n&&(n.remove(),c.delete(n))}},y=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&a.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){if(e.nodeName===t.Shape.HTML){var r=a.getOrCreateEl(e);u(e,r)}}))},v=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.parentElement.style.width="".concat(e.width||0,"px"),a.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,v),l.addEventListener(t.ElementEvent.MOUNTED,f),l.addEventListener(t.ElementEvent.UNMOUNTED,d),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,y),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),s.hooks.endFrame.tap(e.tag,(function(){a.$camera&&i.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){a.$camera&&a.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,v),l.removeEventListener(t.ElementEvent.MOUNTED,f),l.removeEventListener(t.ElementEvent.UNMOUNTED,d),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,y),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,a=t.height,o=this.context.contextService.getDomElement(),i=o.parentNode;if(i){var s="g-canvas-camera",l=i.querySelector("#".concat(s));if(!l){var c=(r||document).createElement("div");c.style.overflow="hidden",c.style.pointerEvents="none",c.style.position="absolute",c.style.left="0px",c.style.top="0px",c.style.width="".concat(n||0,"px"),c.style.height="".concat(a||0,"px");var u=(r||document).createElement("div");l=u,u.id=s,u.style.position="absolute",u.style.left="".concat(o.offsetLeft||0,"px"),u.style.top="".concat(o.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.pointerEvents="none",u.style.width="100%",u.style.height="100%",c.appendChild(u),i.appendChild(c)}return l}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var a=r.parsedStyle.innerHTML;y(a,"String")?n.innerHTML=a:(n.innerHTML="",n.appendChild(a));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].buildCSSText(null,null,"")," ").concat(o[1].buildCSSText(null,null,""));break;case"width":var i=r.parsedStyle.width;n.style.width=p(i)?"".concat(i,"px"):""+i;break;case"height":var s=r.parsedStyle.height;n.style.height=p(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var l=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===l?"auto":l;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var c=r.parsedStyle.fill,u="";t.isCSSRGB(c)?u=c.isNone?"transparent":r.getAttribute("fill"):Array.isArray(c)?u=r.getAttribute("fill"):t.isPattern(c),n.style.background=u;break;case"stroke":var d=r.parsedStyle.stroke,v="";t.isCSSRGB(d)?v=d.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(d)?v=r.getAttribute("stroke"):t.isPattern(d),n.style["border-color"]=v,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:f(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}}}])}();v.tag="HTMLRendering";var m=function(e){function t(){var e,n,a,o;r(this,t);for(var i=arguments.length,u=Array(i),f=0;i>f;f++)u[f]=arguments[f];return n=this,a=t,o=[].concat(u),a=s(a),(e=c(n,l()?Reflect.construct(a,o||[],s(n).constructor):a.apply(n,o))).name="html-renderer",e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new v)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin);e.Plugin=m})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@antv/g-lite")):"function"==typeof define&&define.amd?define(["exports","@antv/g-lite"],t):t(((e="undefined"!=typeof globalThis?globalThis:e||self).G=e.G||{},e.G.HTMLRenderer={}),e.window.G)}(this,(function(e,t){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function a(e){var t=function(e,t){if("object"!=n(e)||!e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var a=r.call(e,t||"default");if("object"!=n(a))return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==n(t)?t:t+""}function o(e,t){for(var r=0;t.length>r;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,a(n.key),n)}}function i(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}function s(e){return s=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},s(e)}function l(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(e){}return(l=function(){return!!e})()}function c(e,t){if(t&&("object"==n(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return function(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(e)}function u(e,t){return u=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},u(e,t)}function f(e){return"number"==typeof e}var y=function(){function e(){r(this,e),this.displayObjectHTMLElementMap=new WeakMap}return i(e,[{key:"joinTransformMatrix",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[0,0,0];return"matrix(".concat([e[0],e[1],e[4],e[5],e[12]+t[0],e[13]+t[1]].join(","),")")}},{key:"apply",value:function(r,n){var a=this,o=r.camera,i=r.renderingContext,s=r.renderingService;this.context=r;var l=i.root.ownerDocument.defaultView,c=l.context.eventService.nativeHTMLMap,u=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())},f=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(o));var n=a.getOrCreateEl(r);a.$camera.appendChild(n),Object.keys(r.attributes).forEach((function(e){a.updateAttribute(e,r)})),u(r,n),c.set(n,r)}},y=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML&&a.$camera){var n=a.getOrCreateEl(r);n&&(n.remove(),c.delete(n))}},d=function(e){var r=e.target;r.nodeName===t.Shape.HTML&&a.updateAttribute(e.attrName,r)},p=function(e){var r=e.target;(r.nodeName===t.Shape.FRAGMENT?r.childNodes:[r]).forEach((function(e){if(e.nodeName===t.Shape.HTML){var r=a.getOrCreateEl(e);u(e,r)}}))},v=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.parentElement.style.width="".concat(e.width||0,"px"),a.$camera.parentElement.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,v),l.addEventListener(t.ElementEvent.MOUNTED,f),l.addEventListener(t.ElementEvent.UNMOUNTED,y),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,p)})),s.hooks.endFrame.tap(e.tag,(function(){a.$camera&&i.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(o.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){a.$camera&&a.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,v),l.removeEventListener(t.ElementEvent.MOUNTED,f),l.removeEventListener(t.ElementEvent.UNMOUNTED,y),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,d),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,p)}))}},{key:"createCamera",value:function(e){var t=this.context.config,r=t.document,n=t.width,a=t.height,o=this.context.contextService.getDomElement(),i=o.parentNode;if(i){var s="g-canvas-camera",l=i.querySelector("#".concat(s));if(!l){var c=(r||document).createElement("div");c.style.overflow="hidden",c.style.pointerEvents="none",c.style.position="absolute",c.style.left="0px",c.style.top="0px",c.style.width="".concat(n||0,"px"),c.style.height="".concat(a||0,"px");var u=(r||document).createElement("div");l=u,u.id=s,u.style.position="absolute",u.style.left="".concat(o.offsetLeft||0,"px"),u.style.top="".concat(o.offsetTop||0,"px"),u.style.transformOrigin="left top",u.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),u.style.pointerEvents="none",u.style.width="100%",u.style.height="100%",c.appendChild(u),i.appendChild(c)}return l}return null}},{key:"getOrCreateEl",value:function(e){var t=this.context.config.document,r=this.displayObjectHTMLElementMap.get(e);return r||(r=(t||document).createElement("div"),e.parsedStyle.$el=r,this.displayObjectHTMLElementMap.set(e,r),e.id&&(r.id=e.id),e.name&&r.setAttribute("name",e.name),e.className&&(r.className=e.className),r.style.position="absolute",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform(),e.getOrigin())),r}},{key:"updateAttribute",value:function(e,r){var n=this.getOrCreateEl(r);switch(e){case"innerHTML":var a=r.parsedStyle.innerHTML;"string"==typeof a?n.innerHTML=a:(n.innerHTML="",n.appendChild(a));break;case"x":n.style.left="".concat(r.parsedStyle.x,"px");break;case"y":n.style.top="".concat(r.parsedStyle.y,"px");break;case"transformOrigin":var o=r.parsedStyle.transformOrigin;n.style["transform-origin"]="".concat(o[0].buildCSSText(null,null,"")," ").concat(o[1].buildCSSText(null,null,""));break;case"width":var i=r.parsedStyle.width;n.style.width=f(i)?"".concat(i,"px"):""+i;break;case"height":var s=r.parsedStyle.height;n.style.height=f(s)?"".concat(s,"px"):""+s;break;case"zIndex":n.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":n.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":var l=r.parsedStyle.pointerEvents;n.style.pointerEvents=void 0===l?"auto":l;break;case"opacity":n.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var c=r.parsedStyle.fill,u="";t.isCSSRGB(c)?u=c.isNone?"transparent":r.getAttribute("fill"):Array.isArray(c)?u=r.getAttribute("fill"):t.isPattern(c),n.style.background=u;break;case"stroke":var y=r.parsedStyle.stroke,d="";t.isCSSRGB(y)?d=y.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(y)?d=r.getAttribute("stroke"):t.isPattern(y),n.style["border-color"]=d,n.style["border-style"]="solid";break;case"lineWidth":n.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":n.style["border-style"]="dashed";break;case"filter":n.style.filter=r.style.filter;break;default:(function(e){return null==e})(r.style[e])||""===r.style[e]||(n.style[e]=r.style[e])}}}])}();y.tag="HTMLRendering";var d=function(e){function t(){var e,n,a,o;r(this,t);for(var i=arguments.length,u=Array(i),f=0;i>f;f++)u[f]=arguments[f];return n=this,a=t,o=[].concat(u),a=s(a),(e=c(n,l()?Reflect.construct(a,o||[],s(n).constructor):a.apply(n,o))).name="html-renderer",e}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&u(e,t)}(t,e),i(t,[{key:"init",value:function(){this.addRenderingPlugin(new y)}},{key:"destroy",value:function(){this.removeAllRenderingPlugins()}}])}(t.AbstractRendererPlugin);e.Plugin=d})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-html-renderer", | ||
"version": "2.1.9", | ||
"version": "2.1.10", | ||
"description": "A G plugin for rendering HTML", | ||
@@ -40,3 +40,3 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "2.2.4" | ||
"@antv/g-lite": "2.2.5" | ||
}, | ||
@@ -43,0 +43,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
123886
+ Added@antv/g-lite@2.2.5(transitive)
- Removed@antv/g-lite@2.2.4(transitive)
Updated@antv/g-lite@2.2.5