@antv/g 5.11.0 → 5.11.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.umd.js +43 -16
- package/dist/index.umd.min.js +1 -1
- package/package.json +9 -9
package/dist/index.umd.js
CHANGED
|
@@ -11228,7 +11228,7 @@
|
|
|
11228
11228
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Content_type#list-of-ts
|
|
11229
11229
|
*/PropertySyntax["LIST_OF_POINTS"]="<list-of-points>";PropertySyntax["PATH"]="<path>";/**
|
|
11230
11230
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/filter#formal_syntax
|
|
11231
|
-
*/PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_PATH"]="<offset-path>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["CLIP_PATH"]="<clip-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));var StyleValueRegistry=exports.Syringe.defineToken('');var LayoutRegistry=exports.Syringe.defineToken('');/**
|
|
11231
|
+
*/PropertySyntax["FILTER"]="<filter>";PropertySyntax["Z_INDEX"]="<z-index>";PropertySyntax["OFFSET_PATH"]="<offset-path>";PropertySyntax["OFFSET_DISTANCE"]="<offset-distance>";PropertySyntax["CLIP_PATH"]="<clip-path>";PropertySyntax["TEXT_PATH"]="<text-path>";PropertySyntax["MARKER"]="<marker>";PropertySyntax["TRANSFORM"]="<transform>";PropertySyntax["TRANSFORM_ORIGIN"]="<transform-origin>";PropertySyntax["TEXT"]="<text>";PropertySyntax["TEXT_TRANSFORM"]="<text-transform>";})(exports.PropertySyntax||(exports.PropertySyntax={}));var StyleValueRegistry=exports.Syringe.defineToken('');var LayoutRegistry=exports.Syringe.defineToken('');/**
|
|
11232
11232
|
* holds useful CSS-related methods.
|
|
11233
11233
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/CSS
|
|
11234
11234
|
*
|
|
@@ -11661,28 +11661,55 @@
|
|
|
11661
11661
|
],BreakingSpaces:[0x0009,0x0020,0x2000,0x2001,0x2002,0x2003,0x2004,0x2005,0x2006,0x2008,0x2009,0x200a,0x205f,0x3000// ideographic space
|
|
11662
11662
|
]};var LATIN_REGEX=/[a-zA-Z0-9\u00C0-\u00D6\u00D8-\u00f6\u00f8-\u00ff!"#$%&'()*+,-./:;]/;// Line breaking rules in CJK (Kinsoku Shori)
|
|
11663
11663
|
// Refer from https://en.wikipedia.org/wiki/Line_breaking_rules_in_East_Asian_languages
|
|
11664
|
-
var regexCannotStartZhCn=/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/;var regexCannotEndZhCn=/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/;var regexCannotStartZhTw=/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/;var regexCannotEndZhTw=/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/;var regexCannotStartJaJp=/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/;var regexCannotEndJaJp=/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;var regexCannotStartKoKr=/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;var regexCannotEndKoKr=/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;var regexCannotStart=new RegExp(regexCannotStartZhCn.source+"|"+regexCannotStartZhTw.source+"|"+regexCannotStartJaJp.source+"|"+regexCannotStartKoKr.source);var regexCannotEnd=new RegExp(regexCannotEndZhCn.source+"|"+regexCannotEndZhTw.source+"|"+regexCannotEndJaJp.source+"|"+regexCannotEndKoKr.source)
|
|
11665
|
-
|
|
11666
|
-
|
|
11664
|
+
var regexCannotStartZhCn=/[!%),.:;?\]}¢°·'""†‡›℃∶、。〃〆〕〗〞﹚﹜!"%'),.:;?!]}~]/;var regexCannotEndZhCn=/[$(£¥·'"〈《「『【〔〖〝﹙﹛$(.[{£¥]/;var regexCannotStartZhTw=/[!),.:;?\]}¢·–—'"•"、。〆〞〕〉》」︰︱︲︳﹐﹑﹒﹔﹕﹖﹘﹚﹜!),.:;?︶︸︺︼︾﹀﹂﹗]|}、]/;var regexCannotEndZhTw=/[([{£¥'"‵〈《「『〔〝︴﹙﹛({︵︷︹︻︽︿﹁﹃﹏]/;var regexCannotStartJaJp=/[)\]}〕〉》」』】〙〗〟'"⦆»ヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻‐゠–〜?!‼⁇⁈⁉・、:;,。.]/;var regexCannotEndJaJp=/[([{〔〈《「『【〘〖〝'"⦅«—...‥〳〴〵]/;var regexCannotStartKoKr=/[!%),.:;?\]}¢°'"†‡℃〆〈《「『〕!%),.:;?]}]/;var regexCannotEndKoKr=/[$([{£¥'"々〇〉》」〔$([{⦆¥₩#]/;var regexCannotStart=new RegExp(regexCannotStartZhCn.source+"|"+regexCannotStartZhTw.source+"|"+regexCannotStartJaJp.source+"|"+regexCannotStartKoKr.source);var regexCannotEnd=new RegExp(regexCannotEndZhCn.source+"|"+regexCannotEndZhTw.source+"|"+regexCannotEndJaJp.source+"|"+regexCannotEndKoKr.source);/**
|
|
11665
|
+
* Borrow from pixi/packages/text/src/TextMetrics.ts
|
|
11666
|
+
*/exports.TextService=/*#__PURE__*/function(){/**
|
|
11667
|
+
* font metrics cache
|
|
11668
|
+
*/function TextService(offscreenCanvas){var _this=this;this.offscreenCanvas=void 0;this.fontMetricsCache={};this.shouldBreakByKinsokuShorui=function(char,nextChar){if(_this.isBreakingSpace(nextChar))return false;if(char){// Line breaking rules in CJK (Kinsoku Shori)
|
|
11669
|
+
if(regexCannotEnd.exec(nextChar)||regexCannotStart.exec(char)){return true;}}return false;};this.trimByKinsokuShorui=function(prev){var next=[].concat(prev);var prevLine=next[next.length-2];if(!prevLine){return prev;}var lastChar=prevLine[prevLine.length-1];next[next.length-2]=prevLine.slice(0,-1);next[next.length-1]=lastChar+next[next.length-1];return next;};this.offscreenCanvas=offscreenCanvas;}/**
|
|
11670
|
+
* Calculates the ascent, descent and fontSize of a given font-style.
|
|
11671
|
+
*/var _proto=TextService.prototype;_proto.measureFont=function measureFont(font,offscreenCanvas){// as this method is used for preparing assets, don't recalculate things if we don't need to
|
|
11672
|
+
if(this.fontMetricsCache[font]){return this.fontMetricsCache[font];}var properties={ascent:0,descent:0,fontSize:0};var canvas=this.offscreenCanvas.getOrCreateCanvas(offscreenCanvas);var context=this.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;var metricsString=TEXT_METRICS.MetricsString+TEXT_METRICS.BaselineSymbol;var width=Math.ceil(context.measureText(metricsString).width);var baseline=Math.ceil(context.measureText(TEXT_METRICS.BaselineSymbol).width);var height=TEXT_METRICS.HeightMultiplier*baseline;baseline=baseline*TEXT_METRICS.BaselineMultiplier|0;// @ts-ignore
|
|
11667
11673
|
canvas.width=width;// @ts-ignore
|
|
11668
11674
|
canvas.height=height;context.fillStyle='#f00';context.fillRect(0,0,width,height);context.font=font;context.textBaseline='alphabetic';context.fillStyle='#000';context.fillText(metricsString,0,baseline);var imagedata=context.getImageData(0,0,width||1,height||1).data;var pixels=imagedata.length;var line=width*4;var i=0;var idx=0;var stop=false;// ascent. scan from top to bottom until we find a non red pixel
|
|
11669
11675
|
for(i=0;i<baseline;++i){for(var j=0;j<line;j+=4){if(imagedata[idx+j]!==255){stop=true;break;}}if(!stop){idx+=line;}else {break;}}properties.ascent=baseline-i;idx=pixels-line;stop=false;// descent. scan from bottom to top until we find a non red pixel
|
|
11670
|
-
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.
|
|
11676
|
+
for(i=height;i>baseline;--i){for(var _j=0;_j<line;_j+=4){if(imagedata[idx+_j]!==255){stop=true;break;}}if(!stop){idx-=line;}else {break;}}properties.descent=i-baseline;properties.fontSize=properties.ascent+properties.descent;this.fontMetricsCache[font]=properties;return properties;};_proto.measureText=function measureText(text,parsedStyle,offscreenCanvas){var fontSize=parsedStyle.fontSize,wordWrap=parsedStyle.wordWrap,strokeHeight=parsedStyle.lineHeight,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,textAlign=parsedStyle.textAlign,letterSpacing=parsedStyle.letterSpacing,textPath=parsedStyle.textPath,textPathSide=parsedStyle.textPathSide,textPathStartOffset=parsedStyle.textPathStartOffset,_parsedStyle$leading=parsedStyle.leading,leading=_parsedStyle$leading===void 0?0:_parsedStyle$leading;var font=toFontString(parsedStyle);var fontProperties=this.measureFont(font,offscreenCanvas);// fallback in case UA disallow canvas data extraction
|
|
11671
11677
|
// (toDataURI, getImageData functions)
|
|
11672
11678
|
if(fontProperties.fontSize===0){fontProperties.fontSize=fontSize;fontProperties.ascent=fontSize;}var context=this.offscreenCanvas.getOrCreateContext(offscreenCanvas);context.font=font;// no overflowing by default
|
|
11673
|
-
parsedStyle.isOverflowing=false;var outputText=wordWrap?this.wordWrap(text,parsedStyle,offscreenCanvas):text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0
|
|
11679
|
+
parsedStyle.isOverflowing=false;var outputText=wordWrap?this.wordWrap(text,parsedStyle,offscreenCanvas):text;var lines=outputText.split(/(?:\r\n|\r|\n)/);var lineWidths=new Array(lines.length);var maxLineWidth=0;// account for textPath
|
|
11680
|
+
if(textPath){var totalPathLength=textPath.getTotalLength();// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
11681
|
+
var startingPoint=textPath.getPoint(0);for(var i=0;i<lines.length;i++){var width=context.measureText(lines[i]).width+(lines[i].length-1)*letterSpacing;// let i = reverse ? lines[0].length - 1 : 0;
|
|
11682
|
+
// reverse ? i >= 0 : i < lines[0].length;
|
|
11683
|
+
// reverse ? i-- : i++
|
|
11684
|
+
// ) {
|
|
11685
|
+
// graphemeInfo = lineBounds[i];
|
|
11686
|
+
// if (positionInPath > totalPathLength) {
|
|
11687
|
+
// positionInPath %= totalPathLength;
|
|
11688
|
+
// } else if (positionInPath < 0) {
|
|
11689
|
+
// positionInPath += totalPathLength;
|
|
11690
|
+
// }
|
|
11691
|
+
// // it would probably much faster to send all the grapheme position for a line
|
|
11692
|
+
// // and calculate path position/angle at once.
|
|
11693
|
+
// this.setGraphemeOnPath(
|
|
11694
|
+
// positionInPath,
|
|
11695
|
+
// graphemeInfo,
|
|
11696
|
+
// startingPoint
|
|
11697
|
+
// );
|
|
11698
|
+
// positionInPath += graphemeInfo.kernedWidth;
|
|
11699
|
+
// }
|
|
11700
|
+
}}else {for(var _i=0;_i<lines.length;_i++){// char width + letterSpacing
|
|
11701
|
+
var _lineWidth=context.measureText(lines[_i]).width+(lines[_i].length-1)*letterSpacing;lineWidths[_i]=_lineWidth;maxLineWidth=Math.max(maxLineWidth,_lineWidth);}var _width=maxLineWidth+lineWidth;// if (dropShadow) {
|
|
11674
11702
|
// width += dropShadowDistance;
|
|
11675
11703
|
// }
|
|
11676
11704
|
var lineHeight=strokeHeight||fontProperties.fontSize+lineWidth;var height=Math.max(lineHeight,fontProperties.fontSize+lineWidth)+(lines.length-1)*(lineHeight+leading);// if (dropShadow) {
|
|
11677
11705
|
// height += dropShadowDistance;
|
|
11678
11706
|
// }
|
|
11679
11707
|
lineHeight+=leading;// handle vertical text baseline
|
|
11680
|
-
var offsetY=0;if(textBaseline==='middle'){offsetY=-height/2;}else if(textBaseline==='bottom'||textBaseline==='alphabetic'||textBaseline==='ideographic'){offsetY=-height;}else if(textBaseline==='top'||textBaseline==='hanging'){offsetY=0;}return {font:font,width:
|
|
11681
|
-
if(textAlign==='center'){offsetX-=width/2;}else if(textAlign==='right'||textAlign==='end'){offsetX-=width;}return new Rectangle(offsetX-lineWidth/2,offsetY+i*lineHeight,width+lineWidth,lineHeight);})};};_proto.wordWrap=function wordWrap(text,parsedStyle,offscreenCanvas){var _this2=this;var _parsedStyle$wordWrap=parsedStyle.wordWrapWidth,wordWrapWidth=_parsedStyle$wordWrap===void 0?0:_parsedStyle$wordWrap,letterSpacing=parsedStyle.letterSpacing,_parsedStyle$maxLines=parsedStyle.maxLines,maxLines=_parsedStyle$maxLines===void 0?Infinity:_parsedStyle$maxLines,textOverflow=parsedStyle.textOverflow;var context=this.offscreenCanvas.getOrCreateContext(offscreenCanvas);var maxWidth=wordWrapWidth+letterSpacing;var ellipsis='';if(textOverflow==='ellipsis'){ellipsis='...';}else if(textOverflow&&textOverflow!=='clip'){ellipsis=textOverflow;}var lines=[];var currentIndex=0;var currentWidth=0;var cache={};var calcWidth=function calcWidth(char){return _this2.getFromCache(char,letterSpacing,cache,context);};var ellipsisWidth=Array.from(ellipsis).reduce(function(prev,cur){return prev+calcWidth(cur);},0);var chars=Array.from(text);for(var i=0;i<chars.length;i++){var char=chars[i];var prevChar=text[i-1];var nextChar=text[i+1];var width=calcWidth(char);if(this.isNewline(char)){currentIndex++;currentWidth=0;lines[currentIndex]='';continue;}if(currentWidth>0&¤tWidth+width>maxWidth){if(currentIndex+1>=maxLines){parsedStyle.isOverflowing=true;// If there is not enough space to display the string itself, it is clipped.
|
|
11708
|
+
var offsetY=0;if(textBaseline==='middle'){offsetY=-height/2;}else if(textBaseline==='bottom'||textBaseline==='alphabetic'||textBaseline==='ideographic'){offsetY=-height;}else if(textBaseline==='top'||textBaseline==='hanging'){offsetY=0;}return {font:font,width:_width,height:height,lines:lines,lineWidths:lineWidths,lineHeight:lineHeight,maxLineWidth:maxLineWidth,fontProperties:fontProperties,lineMetrics:lineWidths.map(function(width,i){var offsetX=0;// handle horizontal text align
|
|
11709
|
+
if(textAlign==='center'){offsetX-=width/2;}else if(textAlign==='right'||textAlign==='end'){offsetX-=width;}return new Rectangle(offsetX-lineWidth/2,offsetY+i*lineHeight,width+lineWidth,lineHeight);})};}};_proto.setGraphemeOnPath=function setGraphemeOnPath(){};_proto.wordWrap=function wordWrap(text,parsedStyle,offscreenCanvas){var _this2=this;var _parsedStyle$wordWrap=parsedStyle.wordWrapWidth,wordWrapWidth=_parsedStyle$wordWrap===void 0?0:_parsedStyle$wordWrap,letterSpacing=parsedStyle.letterSpacing,_parsedStyle$maxLines=parsedStyle.maxLines,maxLines=_parsedStyle$maxLines===void 0?Infinity:_parsedStyle$maxLines,textOverflow=parsedStyle.textOverflow;var context=this.offscreenCanvas.getOrCreateContext(offscreenCanvas);var maxWidth=wordWrapWidth+letterSpacing;var ellipsis='';if(textOverflow==='ellipsis'){ellipsis='...';}else if(textOverflow&&textOverflow!=='clip'){ellipsis=textOverflow;}var lines=[];var currentIndex=0;var currentWidth=0;var cache={};var calcWidth=function calcWidth(char){return _this2.getFromCache(char,letterSpacing,cache,context);};var ellipsisWidth=Array.from(ellipsis).reduce(function(prev,cur){return prev+calcWidth(cur);},0);var chars=Array.from(text);for(var i=0;i<chars.length;i++){var char=chars[i];var prevChar=text[i-1];var nextChar=text[i+1];var width=calcWidth(char);if(this.isNewline(char)){currentIndex++;currentWidth=0;lines[currentIndex]='';continue;}if(currentWidth>0&¤tWidth+width>maxWidth){if(currentIndex+1>=maxLines){parsedStyle.isOverflowing=true;// If there is not enough space to display the string itself, it is clipped.
|
|
11682
11710
|
// @see https://developer.mozilla.org/en-US/docs/Web/CSS/text-overflow#values
|
|
11683
11711
|
if(ellipsisWidth>0&&ellipsisWidth<=maxWidth){// Backspace from line's end.
|
|
11684
|
-
var lastLineWidth=0;var lastLineIndex=0;for(var
|
|
11685
|
-
parsedStyle.metrics={font:'',width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]};return {width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};}var metrics=this.textService.measureText(text,parsedStyle,offscreenCanvas);parsedStyle.metrics=metrics;var width=metrics.width,height=metrics.height,lineHeight=metrics.lineHeight,fontProperties=metrics.fontProperties;// anchor is left-top by default
|
|
11712
|
+
var lastLineWidth=0;var lastLineIndex=0;for(var _i2=0;_i2<lines[currentIndex].length;_i2++){var _width2=calcWidth(lines[currentIndex][_i2]);if(lastLineWidth+_width2+ellipsisWidth>maxWidth){lastLineIndex=_i2;break;}lastLineWidth+=_width2;}lines[currentIndex]=(lines[currentIndex]||'').slice(0,lastLineIndex)+ellipsis;}break;}currentIndex++;currentWidth=0;lines[currentIndex]='';if(this.isBreakingSpace(char)){continue;}if(!this.canBreakInLastChar(char)){lines=this.trimToBreakable(lines);currentWidth=this.sumTextWidthByCache(lines[currentIndex]||'',cache);}if(this.shouldBreakByKinsokuShorui(char,nextChar)){lines=this.trimByKinsokuShorui(lines);currentWidth+=calcWidth(prevChar||'');}}currentWidth+=width;lines[currentIndex]=(lines[currentIndex]||'')+char;}return lines.join('\n');};_proto.isBreakingSpace=function isBreakingSpace(char){if(typeof char!=='string'){return false;}return TEXT_METRICS.BreakingSpaces.indexOf(char.charCodeAt(0))>=0;};_proto.isNewline=function isNewline(char){if(typeof char!=='string'){return false;}return TEXT_METRICS.Newlines.indexOf(char.charCodeAt(0))>=0;};_proto.trimToBreakable=function trimToBreakable(prev){var next=[].concat(prev);var prevLine=next[next.length-2];var index=this.findBreakableIndex(prevLine);if(index===-1||!prevLine)return next;var trimmedChar=prevLine.slice(index,index+1);var isTrimmedWithSpace=this.isBreakingSpace(trimmedChar);var trimFrom=index+1;var trimTo=index+(isTrimmedWithSpace?0:1);next[next.length-1]+=prevLine.slice(trimFrom,prevLine.length);next[next.length-2]=prevLine.slice(0,trimTo);return next;};_proto.canBreakInLastChar=function canBreakInLastChar(char){if(char&&LATIN_REGEX.test(char))return false;return true;};_proto.sumTextWidthByCache=function sumTextWidthByCache(text,cache){return text.split('').reduce(function(sum,c){if(!cache[c])throw Error('cannot count the word without cache');return sum+cache[c];},0);};_proto.findBreakableIndex=function findBreakableIndex(line){for(var i=line.length-1;i>=0;i--){if(!LATIN_REGEX.test(line[i]))return i;}return -1;};_proto.getFromCache=function getFromCache(key,letterSpacing,cache,context){var width=cache[key];if(typeof width!=='number'){var spacing=key.length*letterSpacing;width=context.measureText(key).width+spacing;cache[key]=width;}return width;};return TextService;}();exports.TextService=__decorate([singleton(),__param(0,inject(exports.OffscreenCanvasCreator))],exports.TextService);exports.TextUpdater=/*#__PURE__*/function(){function TextUpdater(textService){this.textService=void 0;this.textService=textService;}var _proto=TextUpdater.prototype;_proto.isReadyToMeasure=function isReadyToMeasure(parsedStyle,object){var text=parsedStyle.text,textAlign=parsedStyle.textAlign,textBaseline=parsedStyle.textBaseline,fontSize=parsedStyle.fontSize,fontStyle=parsedStyle.fontStyle,fontWeight=parsedStyle.fontWeight,fontVariant=parsedStyle.fontVariant,lineWidth=parsedStyle.lineWidth;return text&&fontSize&&fontStyle&&fontWeight&&fontVariant&&textAlign&&textBaseline&&!isNil(lineWidth);};_proto.update=function update(parsedStyle,object){var _object$ownerDocument,_object$ownerDocument2;var text=parsedStyle.text,textAlign=parsedStyle.textAlign,lineWidth=parsedStyle.lineWidth,textBaseline=parsedStyle.textBaseline,dx=parsedStyle.dx,dy=parsedStyle.dy;var _ref=(object===null||object===void 0?void 0:(_object$ownerDocument=object.ownerDocument)===null||_object$ownerDocument===void 0?void 0:(_object$ownerDocument2=_object$ownerDocument.defaultView)===null||_object$ownerDocument2===void 0?void 0:_object$ownerDocument2.getConfig())||{},offscreenCanvas=_ref.offscreenCanvas;if(!this.isReadyToMeasure(parsedStyle,object)){parsedStyle.metrics={font:'',width:0,height:0,lines:[],lineWidths:[],lineHeight:0,maxLineWidth:0,fontProperties:{ascent:0,descent:0,fontSize:0},lineMetrics:[]};return {width:0,height:0,x:0,y:0,offsetX:0,offsetY:0};}var metrics=this.textService.measureText(text,parsedStyle,offscreenCanvas);parsedStyle.metrics=metrics;var width=metrics.width,height=metrics.height,lineHeight=metrics.lineHeight,fontProperties=metrics.fontProperties;// anchor is left-top by default
|
|
11686
11713
|
var halfExtents=[width/2,height/2,0];// default 'left'
|
|
11687
11714
|
var anchor=[0,1];var lineXOffset=0;if(textAlign==='center'){lineXOffset=lineWidth/2;anchor=[0.5,1];}else if(textAlign==='right'||textAlign==='end'){lineXOffset=lineWidth;anchor=[1,1];}var lineYOffset=0;if(textBaseline==='middle'){// eslint-disable-next-line prefer-destructuring
|
|
11688
11715
|
lineYOffset=halfExtents[1];}else if(textBaseline==='top'||textBaseline==='hanging'){lineYOffset=halfExtents[1]*2;}else if(textBaseline==='alphabetic'){lineYOffset=lineHeight-fontProperties.ascent;}else if(textBaseline==='bottom'||textBaseline==='ideographic'){lineYOffset=0;}// TODO: ideographic & bottom
|
|
@@ -12106,7 +12133,7 @@
|
|
|
12106
12133
|
if(isUndefined(value)){return;}if(force||attributeValue!==this.attributes[attributeName]){this.internalSetAttribute(attributeName,attributeValue);_Element.prototype.setAttribute.call(this,attributeName,attributeValue);}}/**
|
|
12107
12134
|
* called when attributes get changed or initialized
|
|
12108
12135
|
*/;_proto.internalSetAttribute=function internalSetAttribute(name,value,parseOptions){var _this$styleValueRegis,_this2=this;if(parseOptions===void 0){parseOptions={};}var renderable=this.renderable;var oldValue=this.attributes[name];var oldParsedValue=this.parsedStyle[name];this.styleValueRegistry.processProperties(this,(_this$styleValueRegis={},_this$styleValueRegis[name]=value,_this$styleValueRegis),parseOptions);// inform clip path targets
|
|
12109
|
-
if(
|
|
12136
|
+
['clipPathTargets','textPathTargets'].forEach(function(pathTargetsName,i){if(_this2.parsedStyle[pathTargetsName]&&_this2.parsedStyle[pathTargetsName].length){var modifiedName=i===0?'clipPath':'textPath';_this2.parsedStyle[pathTargetsName].forEach(function(target){_this2.sceneGraphService.dirtifyToRoot(target);target.dispatchEvent(new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,target,_this2,_this2,modifiedName,MutationEvent.MODIFICATION,_this2,_this2));if(target.isCustomElement&&target.isConnected){if(target.attributeChangedCallback){target.attributeChangedCallback(modifiedName,_this2,_this2);}}});}});// redraw at next frame
|
|
12110
12137
|
renderable.dirty=true;// trigger later
|
|
12111
12138
|
// this.sceneGraphService.pendingEvents.push([ElementEvent.ATTR_MODIFIED, { affectChildren }]);
|
|
12112
12139
|
var newParsedValue=this.parsedStyle[name];if(this.isConnected){if(!mutationEvent){mutationEvent=new MutationEvent(exports.ElementEvent.ATTR_MODIFIED,null,null,null,null,MutationEvent.MODIFICATION,null,null);}mutationEvent.relatedNode=this;mutationEvent.prevValue=oldValue;mutationEvent.newValue=value;mutationEvent.attrName=name;mutationEvent.prevParsedValue=oldParsedValue;mutationEvent.newParsedValue=newParsedValue;this.dispatchEvent(mutationEvent);}if((this.isCustomElement&&this.isConnected||!this.isCustomElement)&&this.attributeChangedCallback){this.attributeChangedCallback(name,oldValue,value,oldParsedValue,newParsedValue);}}// #region transformable
|
|
@@ -12610,9 +12637,9 @@
|
|
|
12610
12637
|
}
|
|
12611
12638
|
});
|
|
12612
12639
|
*/var CSSPropertyClipPath=/*#__PURE__*/function(){function CSSPropertyClipPath(sceneGraphService){this.sceneGraphService=void 0;this.sceneGraphService=sceneGraphService;}var _proto=CSSPropertyClipPath.prototype;_proto.calculator=function calculator(name,oldClipPath,newClipPath,object){var _this=this;// unset
|
|
12613
|
-
if(newClipPath instanceof CSSKeywordValue){newClipPath=null;}
|
|
12614
|
-
if(oldClipPath&&oldClipPath!==newClipPath&&oldClipPath.parsedStyle
|
|
12615
|
-
object.forEach(function(leaf){if(leaf.childNodes.length===0){_this.sceneGraphService.dirtifyToRoot(leaf);}});return newClipPath;};return CSSPropertyClipPath;}();CSSPropertyClipPath=__decorate([singleton({token:{token:CSSProperty,named:exports.PropertySyntax.CLIP_PATH}}),__param(0,inject(SceneGraphService))],CSSPropertyClipPath);var CSSPropertyColor=/*#__PURE__*/function(){function CSSPropertyColor(){this.parser=parseColor;this.mixer=mergeColors;}var _proto=CSSPropertyColor.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){// 'unset' 'none'
|
|
12640
|
+
if(newClipPath instanceof CSSKeywordValue){newClipPath=null;}var pathTargetsName=name==='clipPath'?'clipPathTargets':'textPathTargets';// clear ref to old clip path
|
|
12641
|
+
if(oldClipPath&&oldClipPath!==newClipPath&&oldClipPath.parsedStyle[pathTargetsName]){var index=oldClipPath.parsedStyle[pathTargetsName].indexOf(object);oldClipPath.parsedStyle[pathTargetsName].splice(index,1);}if(newClipPath){if(!newClipPath.parsedStyle[pathTargetsName]){newClipPath.parsedStyle[pathTargetsName]=[];}newClipPath.parsedStyle[pathTargetsName].push(object);}// should affect children
|
|
12642
|
+
object.forEach(function(leaf){if(leaf.childNodes.length===0){_this.sceneGraphService.dirtifyToRoot(leaf);}});return newClipPath;};return CSSPropertyClipPath;}();CSSPropertyClipPath=__decorate([singleton({token:[{token:CSSProperty,named:exports.PropertySyntax.CLIP_PATH},{token:CSSProperty,named:exports.PropertySyntax.TEXT_PATH}]}),__param(0,inject(SceneGraphService))],CSSPropertyClipPath);var CSSPropertyColor=/*#__PURE__*/function(){function CSSPropertyColor(){this.parser=parseColor;this.mixer=mergeColors;}var _proto=CSSPropertyColor.prototype;_proto.calculator=function calculator(name,oldParsed,parsed,object){if(parsed instanceof CSSKeywordValue){// 'unset' 'none'
|
|
12616
12643
|
return parsed.value==='none'?noneColor:transparentColor;}return parsed;};return CSSPropertyColor;}();CSSPropertyColor=__decorate([singleton({token:[{token:CSSProperty,named:exports.PropertySyntax.PAINT},{token:CSSProperty,named:exports.PropertySyntax.COLOR}]})],CSSPropertyColor);var CSSPropertyFilter=/*#__PURE__*/function(){function CSSPropertyFilter(){this.parser=parseFilter;}var _proto=CSSPropertyFilter.prototype;_proto.calculator=function calculator(name,oldParsed,parsed){// unset or none
|
|
12617
12644
|
if(parsed instanceof CSSKeywordValue){return [];}return parsed;};return CSSPropertyFilter;}();CSSPropertyFilter=__decorate([singleton({token:{token:CSSProperty,named:exports.PropertySyntax.FILTER}})],CSSPropertyFilter);function getFontSize(object){var fontSize=object.parsedStyle.fontSize;return isNil(fontSize)?null:fontSize;}/**
|
|
12618
12645
|
* <length> & <percentage>
|
|
@@ -12714,7 +12741,7 @@
|
|
|
12714
12741
|
*/n:'strokeOpacity',int:true,inh:true,d:'1',syntax:exports.PropertySyntax.OPACITY_VALUE},{/**
|
|
12715
12742
|
* background-color is not inheritable
|
|
12716
12743
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Fills_and_Strokes
|
|
12717
|
-
*/n:'fill',int:true,k:['none'],d:'none',syntax:exports.PropertySyntax.PAINT},/**
|
|
12744
|
+
*/n:'fill',int:true,k:['none'],d:'none',syntax:exports.PropertySyntax.PAINT},{n:'fillRule',k:['nonzero','evenodd'],d:'nonzero'},/**
|
|
12718
12745
|
* default to none
|
|
12719
12746
|
* @see https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke#usage_notes
|
|
12720
12747
|
*/{n:'stroke',int:true,k:['none'],d:'none',syntax:exports.PropertySyntax.PAINT},{n:'shadowType',k:['inner','outer','both'],d:'outer',l:true},{n:'shadowColor',int:true,syntax:exports.PropertySyntax.COLOR},{n:'shadowOffsetX',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'shadowOffsetY',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'shadowBlur',int:true,l:true,d:'0',syntax:exports.PropertySyntax.SHADOW_BLUR},{/**
|
|
@@ -12724,7 +12751,7 @@
|
|
|
12724
12751
|
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/visibility#interpolation
|
|
12725
12752
|
*/ // int: true,
|
|
12726
12753
|
d:'visible'},{n:'pointerEvents',inh:true,k:['none','auto','stroke','fill','painted','visible','visiblestroke','visiblefill','visiblepainted',// 'bounding-box',
|
|
12727
|
-
'all'],d:'auto'},{n:'filter',ind:true,l:true,k:['none'],d:'none',syntax:exports.PropertySyntax.FILTER},{n:'clipPath',syntax:exports.PropertySyntax.CLIP_PATH},{n:'transform',p:100,int:true,k:['none'],d:'none',syntax:exports.PropertySyntax.TRANSFORM},{n:'transformOrigin',p:100,// int: true,
|
|
12754
|
+
'all'],d:'auto'},{n:'filter',ind:true,l:true,k:['none'],d:'none',syntax:exports.PropertySyntax.FILTER},{n:'clipPath',syntax:exports.PropertySyntax.CLIP_PATH},{n:'textPath',syntax:exports.PropertySyntax.TEXT_PATH},{n:'textPathSide',k:['left','right'],d:'left'},{n:'textPathStartOffset',l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'transform',p:100,int:true,k:['none'],d:'none',syntax:exports.PropertySyntax.TRANSFORM},{n:'transformOrigin',p:100,// int: true,
|
|
12728
12755
|
d:function d(nodeName){if(nodeName===exports.Shape.CIRCLE||nodeName===exports.Shape.ELLIPSE){return 'center';}if(nodeName===exports.Shape.TEXT){return 'text-anchor';}return 'left top';},l:true,syntax:exports.PropertySyntax.TRANSFORM_ORIGIN},{n:'anchor',p:99,d:function d(nodeName){if(nodeName===exports.Shape.CIRCLE||nodeName===exports.Shape.ELLIPSE){return '0.5 0.5';}return '0 0';},l:true,syntax:exports.PropertySyntax.LENGTH_PERCENTAGE_12},// <circle> & <ellipse>
|
|
12729
12756
|
{n:'cx',int:true,d:'0',syntax:exports.PropertySyntax.COORDINATE},{n:'cy',int:true,d:'0',syntax:exports.PropertySyntax.COORDINATE},{n:'r',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'rx',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},{n:'ry',int:true,l:true,d:'0',syntax:exports.PropertySyntax.LENGTH_PERCENTAGE},// Rect Image Group
|
|
12730
12757
|
{// x in local space
|