@antv/g-plugin-html-renderer
Advanced tools
Comparing version 1.0.0-alpha.20 to 1.0.0-alpha.21
@@ -15,2 +15,2 @@ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@antv/g"),require("mana-syringe")):"function"==typeof define&&define.amd?define(["@antv/g","mana-syringe"],t):"object"==typeof exports?exports.HTMLRenderer=t(require("@antv/g"),require("mana-syringe")):(e.G=e.G||{},e.G.HTMLRenderer=t(e.G,e.G.ManaSyringe))}(window,(function(e,t){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=2)}([function(t,n){t.exports=e},function(e,n){e.exports=t},function(e,t,n){"use strict";n.r(t),n.d(t,"Plugin",(function(){return O}));var r=n(1); | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */function o(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function i(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;Object.create;var a=n(0),c={}.toString,u=function(e,t){return c.call(e)==="[object "+t+"]"},f=function(e){return u(e,"Function")},p=function(e){return Array.isArray?Array.isArray(e):u(e,"Array")},l=function(e){var t=typeof e;return null!==e&&"object"===t||"function"===t};var d=function(e,t){if(e)if(p(e))for(var n=0,r=e.length;n<r&&!1!==t(e[n],n);n++);else if(l(e))for(var o in e)if(e.hasOwnProperty(o)&&!1===t(e[o],o))break};Object.keys;var s=Array.prototype,y=(s.splice,s.indexOf,Array.prototype.splice,function(e){return u(e,"String")});Object.prototype.hasOwnProperty;var v=function(e){return u(e,"Number")};Number.isInteger&&Number.isInteger;Math.PI,parseInt,Math.PI;var g=Object.values?function(e){return Object.values(e)}:function(e){var t=[];return d(e,(function(n,r){f(e)&&"prototype"===r||t.push(n)})),t};Object.prototype;Object.prototype.hasOwnProperty;var m;Object.prototype.hasOwnProperty;(function(e,t){if(!f(e))throw new TypeError("Expected a function");var n=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var c=e.apply(this,r);return a.set(i,c),c};n.cache=new Map})((function(e,t){void 0===t&&(t={});var n=t.fontSize,r=t.fontFamily,o=t.fontWeight,i=t.fontStyle,a=t.fontVariant;return m||(m=document.createElement("canvas").getContext("2d")),m.font=[i,a,o,n+"px",r].join(" "),m.measureText(y(e)?e:"").width}),(function(e,t){return void 0===t&&(t={}),function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,c=i.length;a<c;a++,o++)r[o]=i[a];return r}([e],g(t)).join("")})),function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var n=this.map[e];return void 0===n?t:n},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var b=function(){function e(){}var t;return t=e,e.prototype.apply=function(e){var n=this,r=function(e){var t=e.target;if(t.nodeName===a.SHAPE.HTML){var r=t.parsedStyle.innerHTML,o="g-html-"+t.entity.getName(),i=n.contextService.getDomElement().parentNode;if(!i.querySelector("#"+o)){var c=document.createElement("div");t.parsedStyle.$el=c,c.id=o,y(r)?c.innerHTML=r:c.appendChild(r),i.appendChild(c)}}},o=function(e){var t=e.target;if(t.nodeName===a.SHAPE.HTML){var r="g-html-"+t.entity.getName(),o=n.contextService.getDomElement().parentNode,i=o.querySelector("#"+r);i&&o.removeChild(i)}};e.hooks.init.tap(t.tag,(function(){n.renderingContext.root.addEventListener(a.ElementEvent.MOUNTED,r),n.renderingContext.root.addEventListener(a.ElementEvent.UNMOUNTED,o)})),e.hooks.destroy.tap(t.tag,(function(){n.renderingContext.root.removeEventListener(a.ElementEvent.MOUNTED,r),n.renderingContext.root.removeEventListener(a.ElementEvent.UNMOUNTED,o)})),e.hooks.render.tap(t.tag,(function(e){if(e.nodeName===a.SHAPE.HTML){var t="g-html-"+e.entity.getName(),r=n.contextService.getDomElement().parentNode.querySelector("#"+t);n.updateCSSStyle(r,e.parsedStyle,e)}}))},e.prototype.updateCSSStyle=function(e,t,n){var r=t.zIndex,o=void 0===r?0:r,i=t.visibility,c=void 0===i?"visible":i,u=t.opacity,f=void 0===u?1:u,p=t.fill,l=t.lineWidth,d=void 0===l?0:l,s=t.lineDash,y=t.stroke,v=t.anchor,g=t.width,m=void 0===g?0:g,b=t.height,h=void 0===b?0:b,O=t.style,j=void 0===O?"":O,E=t.className,S=void 0===E?"":E,x={position:"absolute",top:0,left:0};if(x.width=m+"px",x.height=h+"px",x.transform="matrix3d("+n.getWorldTransform().join(",")+")",v&&(x.transform+=" translate("+100*v[0]+"%, "+100*v[0]+"%)"),n.style.transformOrigin&&(x["transform-origin"]=n.style.transformOrigin),x["z-index"]=o,x.visibility=c,x.opacity=f,p){var P="";if(p.type===a.PARSED_COLOR_TYPE.Constant)P=p.formatted;else if(p.type===a.PARSED_COLOR_TYPE.LinearGradient){P="linear-gradient(to right, "+p.value.steps.map((function(e){return e[1]+" "+100*Number(e[0])+"%"})).join(",")+");"}else p.type===a.PARSED_COLOR_TYPE.RadialGradient||(p.type,a.PARSED_COLOR_TYPE.Pattern);x.background=P}x["border-width"]=d+"px",y&&y.type===a.PARSED_COLOR_TYPE.Constant&&(x["border-color"]=y.formatted,x["border-style"]="solid"),s&&(x["border-style"]="dashed"),n.style.filter&&(x.filter=n.style.filter),S&&(Array.isArray(S)?S.forEach((function(t){e.classList.add(t)})):e.classList.add(S)),e.setAttribute("style",Object.keys(x).map((function(e){return e+":"+x[e]})).join(";")+j)},e.tag="HTMLRenderingPlugin",o([Object(r.inject)(a.ContextService),i("design:type",Object)],e.prototype,"contextService",void 0),o([Object(r.inject)(a.RenderingContext),i("design:type",Object)],e.prototype,"renderingContext",void 0),e=t=o([Object(r.singleton)({contrib:a.RenderingPluginContribution})],e)}(),h=Object(r.Module)((function(e){e(b)})),O=function(){function e(){}return e.prototype.init=function(e){e.load(h,!0)},e.prototype.destroy=function(e){e.remove(b)},e}()}])})); | ||
***************************************************************************** */function o(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var c=e.length-1;c>=0;c--)(o=e[c])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a}function i(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}Object.create;Object.create;var a=n(0),c={}.toString,u=function(e,t){return c.call(e)==="[object "+t+"]"},f=function(e){return u(e,"Function")},p=function(e){return Array.isArray?Array.isArray(e):u(e,"Array")},l=function(e){var t=typeof e;return null!==e&&"object"===t||"function"===t};var d=function(e,t){if(e)if(p(e))for(var n=0,r=e.length;n<r&&!1!==t(e[n],n);n++);else if(l(e))for(var o in e)if(e.hasOwnProperty(o)&&!1===t(e[o],o))break};Object.keys;var s=Array.prototype,y=(s.splice,s.indexOf,Array.prototype.splice,function(e){return u(e,"String")});Object.prototype.hasOwnProperty;var v=function(e){return u(e,"Number")};Number.isInteger&&Number.isInteger;Math.PI,parseInt,Math.PI;var g=Object.values?function(e){return Object.values(e)}:function(e){var t=[];return d(e,(function(n,r){f(e)&&"prototype"===r||t.push(n)})),t};Object.prototype;Object.prototype.hasOwnProperty;var m;Object.prototype.hasOwnProperty;(function(e,t){if(!f(e))throw new TypeError("Expected a function");var n=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];var i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var c=e.apply(this,r);return a.set(i,c),c};n.cache=new Map})((function(e,t){void 0===t&&(t={});var n=t.fontSize,r=t.fontFamily,o=t.fontWeight,i=t.fontStyle,a=t.fontVariant;return m||(m=document.createElement("canvas").getContext("2d")),m.font=[i,a,o,n+"px",r].join(" "),m.measureText(y(e)?e:"").width}),(function(e,t){return void 0===t&&(t={}),function(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),o=0;for(t=0;t<n;t++)for(var i=arguments[t],a=0,c=i.length;a<c;a++,o++)r[o]=i[a];return r}([e],g(t)).join("")})),function(){function e(){this.map={}}e.prototype.has=function(e){return void 0!==this.map[e]},e.prototype.get=function(e,t){var n=this.map[e];return void 0===n?t:n},e.prototype.set=function(e,t){this.map[e]=t},e.prototype.clear=function(){this.map={}},e.prototype.delete=function(e){delete this.map[e]},e.prototype.size=function(){return Object.keys(this.map).length}}();var b=function(){function e(){}var t;return t=e,e.prototype.apply=function(e){var n=this,r=function(e){var t=e.target;if(t.nodeName===a.SHAPE.HTML){var r=t.parsedStyle.innerHTML,o="g-html-"+t.entity,i=n.contextService.getDomElement().parentNode;if(!i.querySelector("#"+o)){var c=document.createElement("div");t.parsedStyle.$el=c,c.id=o,y(r)?c.innerHTML=r:c.appendChild(r),i.appendChild(c)}}},o=function(e){var t=e.target;if(t.nodeName===a.SHAPE.HTML){var r="g-html-"+t.entity,o=n.contextService.getDomElement().parentNode,i=o.querySelector("#"+r);i&&o.removeChild(i)}};e.hooks.init.tap(t.tag,(function(){n.renderingContext.root.addEventListener(a.ElementEvent.MOUNTED,r),n.renderingContext.root.addEventListener(a.ElementEvent.UNMOUNTED,o)})),e.hooks.destroy.tap(t.tag,(function(){n.renderingContext.root.removeEventListener(a.ElementEvent.MOUNTED,r),n.renderingContext.root.removeEventListener(a.ElementEvent.UNMOUNTED,o)})),e.hooks.render.tap(t.tag,(function(e){if(e.nodeName===a.SHAPE.HTML){var t="g-html-"+e.entity,r=n.contextService.getDomElement().parentNode.querySelector("#"+t);n.updateCSSStyle(r,e.parsedStyle,e)}}))},e.prototype.updateCSSStyle=function(e,t,n){var r=t.zIndex,o=void 0===r?0:r,i=t.visibility,c=void 0===i?"visible":i,u=t.opacity,f=void 0===u?1:u,p=t.fill,l=t.lineWidth,d=void 0===l?0:l,s=t.lineDash,y=t.stroke,v=t.anchor,g=t.width,m=void 0===g?0:g,b=t.height,h=void 0===b?0:b,O=t.style,j=void 0===O?"":O,E=t.className,S=void 0===E?"":E,x={position:"absolute",top:0,left:0};if(x.width=m+"px",x.height=h+"px",x.transform="matrix3d("+n.getWorldTransform().join(",")+")",v&&(x.transform+=" translate("+100*v[0]+"%, "+100*v[0]+"%)"),n.style.transformOrigin&&(x["transform-origin"]=n.style.transformOrigin),x["z-index"]=o,x.visibility=c,x.opacity=f,p){var P="";if(p.type===a.PARSED_COLOR_TYPE.Constant)P=p.formatted;else if(p.type===a.PARSED_COLOR_TYPE.LinearGradient){P="linear-gradient(to right, "+p.value.steps.map((function(e){return e[1]+" "+100*Number(e[0])+"%"})).join(",")+");"}else p.type===a.PARSED_COLOR_TYPE.RadialGradient||(p.type,a.PARSED_COLOR_TYPE.Pattern);x.background=P}x["border-width"]=d+"px",y&&y.type===a.PARSED_COLOR_TYPE.Constant&&(x["border-color"]=y.formatted,x["border-style"]="solid"),s&&(x["border-style"]="dashed"),n.style.filter&&(x.filter=n.style.filter),S&&(Array.isArray(S)?S.forEach((function(t){e.classList.add(t)})):e.classList.add(S)),e.setAttribute("style",Object.keys(x).map((function(e){return e+":"+x[e]})).join(";")+j)},e.tag="HTMLRenderingPlugin",o([Object(r.inject)(a.ContextService),i("design:type",Object)],e.prototype,"contextService",void 0),o([Object(r.inject)(a.RenderingContext),i("design:type",Object)],e.prototype,"renderingContext",void 0),e=t=o([Object(r.singleton)({contrib:a.RenderingPluginContribution})],e)}(),h=Object(r.Module)((function(e){e(b)})),O=function(){function e(){}return e.prototype.init=function(e){e.load(h,!0)},e.prototype.destroy=function(e){e.remove(b)},e}()}])})); |
@@ -22,3 +22,3 @@ import { __decorate, __metadata } from "tslib"; | ||
var innerHTML = object.parsedStyle.innerHTML; | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -49,3 +49,3 @@ var $container = _this.contextService.getDomElement().parentNode; | ||
if (object.nodeName === SHAPE.HTML) { | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -74,3 +74,3 @@ var $container = _this.contextService.getDomElement().parentNode; | ||
if (object.nodeName === SHAPE.HTML) { | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -77,0 +77,0 @@ var $container = _this.contextService.getDomElement().parentNode; |
@@ -33,3 +33,3 @@ "use strict"; | ||
var innerHTML = object.parsedStyle.innerHTML; | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -60,3 +60,3 @@ var $container = _this.contextService.getDomElement().parentNode; | ||
if (object.nodeName === _g2.SHAPE.HTML) { | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -85,3 +85,3 @@ var $container = _this.contextService.getDomElement().parentNode; | ||
if (object.nodeName === _g2.SHAPE.HTML) { | ||
var existedId = HTML_PREFIX + object.entity.getName(); | ||
var existedId = HTML_PREFIX + object.entity; | ||
@@ -88,0 +88,0 @@ var $container = _this.contextService.getDomElement().parentNode; |
{ | ||
"name": "@antv/g-plugin-html-renderer", | ||
"version": "1.0.0-alpha.20", | ||
"version": "1.0.0-alpha.21", | ||
"description": "A G plugin for rendering HTML", | ||
@@ -35,6 +35,3 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^25.0.0", | ||
"npm-run-all": "^4.1.5", | ||
"webpack": "^4.39.3", | ||
"webpack-cli": "^3.3.7" | ||
"@types/jest": "^25.0.0" | ||
}, | ||
@@ -49,3 +46,3 @@ "peerDependencies": { | ||
"homepage": "https://github.com/antvis/g#readme", | ||
"gitHead": "c0f918d5477e3099b9bfa3ecb077cc411c0b2e3a" | ||
"gitHead": "d09726ac85b8738d53c97002a98848b4a450bfcd" | ||
} |
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
1
24712