@antv/g-plugin-html-renderer
Advanced tools
Comparing version 1.9.22 to 1.9.23
@@ -1,2 +0,2 @@ | ||
import { __extends } from 'tslib'; | ||
import { __extends, __spreadArray, __read } from 'tslib'; | ||
import { CanvasEvent, ElementEvent, RenderReason, isCSSRGB, isPattern, Shape, AbstractRendererPlugin } from '@antv/g-lite'; | ||
@@ -25,2 +25,3 @@ import { isNil, isNumber, isString } from '@antv/util'; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
var nativeHTMLMap = canvas.context.eventService.nativeHTMLMap; | ||
var setTransform = function (object, $el) { | ||
@@ -49,3 +50,3 @@ $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform()); | ||
setTransform(object, $el_1); | ||
_this.context.nativeHTMLMap.set($el_1, object); | ||
nativeHTMLMap.set($el_1, object); | ||
} | ||
@@ -59,3 +60,3 @@ }; | ||
$el.remove(); | ||
_this.context.nativeHTMLMap.delete($el); | ||
nativeHTMLMap.delete($el); | ||
} | ||
@@ -283,3 +284,3 @@ } | ||
function Plugin() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super.apply(this, __spreadArray([], __read(arguments), false)) || this; | ||
_this.name = 'html-renderer'; | ||
@@ -286,0 +287,0 @@ return _this; |
@@ -27,2 +27,3 @@ 'use strict'; | ||
var canvas = renderingContext.root.ownerDocument.defaultView; | ||
var nativeHTMLMap = canvas.context.eventService.nativeHTMLMap; | ||
var setTransform = function (object, $el) { | ||
@@ -51,3 +52,3 @@ $el.style.transform = _this.joinTransformMatrix(object.getWorldTransform()); | ||
setTransform(object, $el_1); | ||
_this.context.nativeHTMLMap.set($el_1, object); | ||
nativeHTMLMap.set($el_1, object); | ||
} | ||
@@ -61,3 +62,3 @@ }; | ||
$el.remove(); | ||
_this.context.nativeHTMLMap.delete($el); | ||
nativeHTMLMap.delete($el); | ||
} | ||
@@ -285,3 +286,3 @@ } | ||
function Plugin() { | ||
var _this = _super !== null && _super.apply(this, arguments) || this; | ||
var _this = _super.apply(this, tslib.__spreadArray([], tslib.__read(arguments), false)) || this; | ||
_this.name = 'html-renderer'; | ||
@@ -288,0 +289,0 @@ return _this; |
@@ -1,2 +0,2 @@ | ||
!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";var n=function(e,t){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])},n(e,t)};var r=function(e){return null==e},a={}.toString,i=function(e,t){return a.call(e)==="[object "+t+"]"},o=function(e){return i(e,"Number")},s=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(n,r){var a=this,i=n.camera,o=n.renderingContext,s=n.renderingService;this.context=n;var l=o.root.ownerDocument.defaultView,c=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform())},d=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(i));var o=a.getOrCreateEl(n);if(a.$camera.appendChild(o),r.enableCSSParsing){var s=n.ownerDocument.documentElement.attributes;Object.keys(s).forEach((function(e){o.style[e]=s[e]}))}Object.keys(n.attributes).forEach((function(e){a.updateAttribute(e,n)})),c(n,o),a.context.nativeHTMLMap.set(o,n)}},p=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML&&a.$camera){var r=a.getOrCreateEl(n);r&&(r.remove(),a.context.nativeHTMLMap.delete(r))}},f=function(e){var n=e.target;n.nodeName===t.Shape.HTML&&a.updateAttribute(e.attrName,n)},y=function(e){var n=e.target;if(n.nodeName===t.Shape.HTML){var r=a.getOrCreateEl(n);c(n,r)}},u=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.style.width="".concat(e.width||0,"px"),a.$camera.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,u),l.addEventListener(t.ElementEvent.MOUNTED,d),l.addEventListener(t.ElementEvent.UNMOUNTED,p),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,f),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,y)})),s.hooks.endFrame.tap(e.tag,(function(){a.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(i.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){a.$camera&&a.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,u),l.removeEventListener(t.ElementEvent.MOUNTED,d),l.removeEventListener(t.ElementEvent.UNMOUNTED,p),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,f),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,y)}))},e.prototype.createCamera=function(e){var t=this.context.config,n=t.document,r=t.width,a=t.height,i=this.context.contextService.getDomElement(),o=i.parentNode;if(o){var s="g-canvas-camera",l=o.querySelector("#"+s);if(!l){var c=(n||document).createElement("div");l=c,c.id=s,c.style.position="absolute",c.style.left="".concat(i.offsetLeft||0,"px"),c.style.top="".concat(i.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width="".concat(r||0,"px"),c.style.height="".concat(a||0,"px"),o.appendChild(c)}return l}return null},e.prototype.getOrCreateEl=function(e){var t=this.context.config.document,n=this.displayObjectHTMLElementMap.get(e);return n||(n=(t||document).createElement("div"),e.parsedStyle.$el=n,this.displayObjectHTMLElementMap.set(e,n),e.id&&(n.id=e.id),e.name&&n.setAttribute("name",e.name),e.className&&(n.className=e.className),n.style.position="absolute",n.style.left="0px",n.style.top="0px",n.style["will-change"]="transform",n.style.transform=this.joinTransformMatrix(e.getWorldTransform())),n},e.prototype.updateAttribute=function(e,n){var a=this.getOrCreateEl(n);switch(e){case"innerHTML":var s=n.parsedStyle.innerHTML;i(s,"String")?a.innerHTML=s:(a.innerHTML="",a.appendChild(s));break;case"transformOrigin":var l=n.parsedStyle.transformOrigin;a.style["transform-origin"]="".concat(l[0].value," ").concat(l[1].value);break;case"width":if(this.context.enableCSSParsing){var c=n.computedStyleMap().get("width");a.style.width=""+c}else{a.style.width=o(c=n.parsedStyle.width)?"".concat(c,"px"):""+c}break;case"height":if(this.context.enableCSSParsing){var d=n.computedStyleMap().get("height");a.style.height=""+d}else{a.style.height=o(d=n.parsedStyle.height)?"".concat(d,"px"):""+d}break;case"zIndex":a.style["z-index"]="".concat(n.parsedStyle.zIndex);break;case"visibility":a.style.visibility=n.parsedStyle.visibility;break;case"pointerEvents":a.style.pointerEvents=n.parsedStyle.pointerEvents;break;case"opacity":a.style.opacity="".concat(n.parsedStyle.opacity);break;case"fill":var p=n.parsedStyle.fill,f="";t.isCSSRGB(p)?f=p.isNone?"transparent":n.getAttribute("fill"):Array.isArray(p)?f=n.getAttribute("fill"):t.isPattern(p),a.style.background=f;break;case"stroke":var y=n.parsedStyle.stroke,u="";t.isCSSRGB(y)?u=y.isNone?"transparent":n.getAttribute("stroke"):Array.isArray(y)?u=n.getAttribute("stroke"):t.isPattern(y),a.style["border-color"]=u,a.style["border-style"]="solid";break;case"lineWidth":a.style["border-width"]="".concat(n.parsedStyle.lineWidth||0,"px");break;case"lineDash":a.style["border-style"]="dashed";break;case"filter":a.style.filter=n.style.filter;break;default:"x"!==e&&"y"!==e&&(r(n.style[e])||""===n.style[e]||(a.style[e]=n.style[e]))}},e.tag="HTMLRendering",e}(),l=function(e){function t(){var t=null!==e&&e.apply(this,arguments)||this;return t.name="html-renderer",t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function r(){this.constructor=e}n(e,t),e.prototype=null===t?Object.create(t):(r.prototype=t.prototype,new r)}(t,e),t.prototype.init=function(){this.addRenderingPlugin(new s)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin);e.Plugin=l})); | ||
!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";var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=t[r])},r(e,t)};var n=function(e){return null==e},a={}.toString,i=function(e,t){return a.call(e)==="[object "+t+"]"},o=function(e){return i(e,"Number")},s=function(){function e(){this.displayObjectHTMLElementMap=new WeakMap}return e.prototype.joinTransformMatrix=function(e){return"matrix(".concat([e[0],e[1],e[4],e[5],e[12],e[13]].join(","),")")},e.prototype.apply=function(r,n){var a=this,i=r.camera,o=r.renderingContext,s=r.renderingService;this.context=r;var l=o.root.ownerDocument.defaultView,c=l.context.eventService.nativeHTMLMap,p=function(e,t){t.style.transform=a.joinTransformMatrix(e.getWorldTransform())},d=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){a.$camera||(a.$camera=a.createCamera(i));var o=a.getOrCreateEl(r);if(a.$camera.appendChild(o),n.enableCSSParsing){var s=r.ownerDocument.documentElement.attributes;Object.keys(s).forEach((function(e){o.style[e]=s[e]}))}Object.keys(r.attributes).forEach((function(e){a.updateAttribute(e,r)})),p(r,o),c.set(o,r)}},f=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)},u=function(e){var r=e.target;if(r.nodeName===t.Shape.HTML){var n=a.getOrCreateEl(r);p(r,n)}},m=function(){if(a.$camera){var e=a.context.config,t=e.height;a.$camera.style.width="".concat(e.width||0,"px"),a.$camera.style.height="".concat(t||0,"px")}};s.hooks.init.tap(e.tag,(function(){l.addEventListener(t.CanvasEvent.RESIZE,m),l.addEventListener(t.ElementEvent.MOUNTED,d),l.addEventListener(t.ElementEvent.UNMOUNTED,f),l.addEventListener(t.ElementEvent.ATTR_MODIFIED,y),l.addEventListener(t.ElementEvent.BOUNDS_CHANGED,u)})),s.hooks.endFrame.tap(e.tag,(function(){a.$camera&&o.renderReasons.has(t.RenderReason.CAMERA_CHANGED)&&(a.$camera.style.transform=a.joinTransformMatrix(i.getOrthoMatrix()))})),s.hooks.destroy.tap(e.tag,(function(){a.$camera&&a.$camera.remove(),l.removeEventListener(t.CanvasEvent.RESIZE,m),l.removeEventListener(t.ElementEvent.MOUNTED,d),l.removeEventListener(t.ElementEvent.UNMOUNTED,f),l.removeEventListener(t.ElementEvent.ATTR_MODIFIED,y),l.removeEventListener(t.ElementEvent.BOUNDS_CHANGED,u)}))},e.prototype.createCamera=function(e){var t=this.context.config,r=t.document,n=t.width,a=t.height,i=this.context.contextService.getDomElement(),o=i.parentNode;if(o){var s="g-canvas-camera",l=o.querySelector("#"+s);if(!l){var c=(r||document).createElement("div");l=c,c.id=s,c.style.position="absolute",c.style.left="".concat(i.offsetLeft||0,"px"),c.style.top="".concat(i.offsetTop||0,"px"),c.style.transformOrigin="left top",c.style.transform=this.joinTransformMatrix(e.getOrthoMatrix()),c.style.overflow="hidden",c.style.pointerEvents="none",c.style.width="".concat(n||0,"px"),c.style.height="".concat(a||0,"px"),o.appendChild(c)}return l}return null},e.prototype.getOrCreateEl=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.left="0px",r.style.top="0px",r.style["will-change"]="transform",r.style.transform=this.joinTransformMatrix(e.getWorldTransform())),r},e.prototype.updateAttribute=function(e,r){var a=this.getOrCreateEl(r);switch(e){case"innerHTML":var s=r.parsedStyle.innerHTML;i(s,"String")?a.innerHTML=s:(a.innerHTML="",a.appendChild(s));break;case"transformOrigin":var l=r.parsedStyle.transformOrigin;a.style["transform-origin"]="".concat(l[0].value," ").concat(l[1].value);break;case"width":if(this.context.enableCSSParsing){var c=r.computedStyleMap().get("width");a.style.width=""+c}else{a.style.width=o(c=r.parsedStyle.width)?"".concat(c,"px"):""+c}break;case"height":if(this.context.enableCSSParsing){var p=r.computedStyleMap().get("height");a.style.height=""+p}else{a.style.height=o(p=r.parsedStyle.height)?"".concat(p,"px"):""+p}break;case"zIndex":a.style["z-index"]="".concat(r.parsedStyle.zIndex);break;case"visibility":a.style.visibility=r.parsedStyle.visibility;break;case"pointerEvents":a.style.pointerEvents=r.parsedStyle.pointerEvents;break;case"opacity":a.style.opacity="".concat(r.parsedStyle.opacity);break;case"fill":var d=r.parsedStyle.fill,f="";t.isCSSRGB(d)?f=d.isNone?"transparent":r.getAttribute("fill"):Array.isArray(d)?f=r.getAttribute("fill"):t.isPattern(d),a.style.background=f;break;case"stroke":var y=r.parsedStyle.stroke,u="";t.isCSSRGB(y)?u=y.isNone?"transparent":r.getAttribute("stroke"):Array.isArray(y)?u=r.getAttribute("stroke"):t.isPattern(y),a.style["border-color"]=u,a.style["border-style"]="solid";break;case"lineWidth":a.style["border-width"]="".concat(r.parsedStyle.lineWidth||0,"px");break;case"lineDash":a.style["border-style"]="dashed";break;case"filter":a.style.filter=r.style.filter;break;default:"x"!==e&&"y"!==e&&(n(r.style[e])||""===r.style[e]||(a.style[e]=r.style[e]))}},e.tag="HTMLRendering",e}(),l=function(e){function t(){var t=e.apply(this,function(e,t,r){if(r||2===arguments.length)for(var n,a=0,i=t.length;i>a;a++)!n&&a in t||(n||(n=Array.prototype.slice.call(t,0,a)),n[a]=t[a]);return e.concat(n||Array.prototype.slice.call(t))}([],function(e,t){var r="function"==typeof Symbol&&e[Symbol.iterator];if(!r)return e;var n,a,i=r.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(n=i.next()).done;)o.push(n.value)}catch(e){a={error:e}}finally{try{n&&!n.done&&(r=i.return)&&r.call(i)}finally{if(a)throw a.error}}return o}(arguments),!1))||this;return t.name="html-renderer",t}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Class extends value "+t+" is not a constructor or null");function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}(t,e),t.prototype.init=function(){this.addRenderingPlugin(new s)},t.prototype.destroy=function(){this.removeAllRenderingPlugins()},t}(t.AbstractRendererPlugin);e.Plugin=l})); | ||
//# sourceMappingURL=index.umd.min.js.map |
{ | ||
"name": "@antv/g-plugin-html-renderer", | ||
"version": "1.9.22", | ||
"version": "1.9.23", | ||
"description": "A G plugin for rendering HTML", | ||
@@ -38,3 +38,3 @@ "keywords": [ | ||
"tslib": "^2.5.3", | ||
"@antv/g-lite": "1.2.19" | ||
"@antv/g-lite": "1.2.20" | ||
}, | ||
@@ -41,0 +41,0 @@ "publishConfig": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
634
85114
+ Added@antv/g-lite@1.2.20(transitive)
- Removed@antv/g-lite@1.2.19(transitive)
Updated@antv/g-lite@1.2.20