1 line
54 KiB
JSON
1 line
54 KiB
JSON
{"ast":null,"code":"import \"core-js/modules/es.regexp.exec.js\";\nimport \"core-js/modules/es.string.split.js\";\nimport \"core-js/modules/es.array.join.js\";\nimport \"core-js/modules/es.array.slice.js\";\nimport * as imageHelper from '../helper/image.js';\nimport { extend, retrieve2, retrieve3, reduce } from '../../core/util.js';\nimport { getLineHeight, getWidth, parsePercent } from '../../contain/text.js';\nvar STYLE_REG = /\\{([a-zA-Z0-9_]+)\\|([^}]*)\\}/g;\nexport function truncateText(text, containerWidth, font, ellipsis, options) {\n if (!containerWidth) {\n return '';\n }\n\n var textLines = (text + '').split('\\n');\n options = prepareTruncateOptions(containerWidth, font, ellipsis, options);\n\n for (var i = 0, len = textLines.length; i < len; i++) {\n textLines[i] = truncateSingleLine(textLines[i], options);\n }\n\n return textLines.join('\\n');\n}\n\nfunction prepareTruncateOptions(containerWidth, font, ellipsis, options) {\n options = options || {};\n var preparedOpts = extend({}, options);\n preparedOpts.font = font;\n ellipsis = retrieve2(ellipsis, '...');\n preparedOpts.maxIterations = retrieve2(options.maxIterations, 2);\n var minChar = preparedOpts.minChar = retrieve2(options.minChar, 0);\n preparedOpts.cnCharWidth = getWidth('国', font);\n var ascCharWidth = preparedOpts.ascCharWidth = getWidth('a', font);\n preparedOpts.placeholder = retrieve2(options.placeholder, '');\n var contentWidth = containerWidth = Math.max(0, containerWidth - 1);\n\n for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {\n contentWidth -= ascCharWidth;\n }\n\n var ellipsisWidth = getWidth(ellipsis, font);\n\n if (ellipsisWidth > contentWidth) {\n ellipsis = '';\n ellipsisWidth = 0;\n }\n\n contentWidth = containerWidth - ellipsisWidth;\n preparedOpts.ellipsis = ellipsis;\n preparedOpts.ellipsisWidth = ellipsisWidth;\n preparedOpts.contentWidth = contentWidth;\n preparedOpts.containerWidth = containerWidth;\n return preparedOpts;\n}\n\nfunction truncateSingleLine(textLine, options) {\n var containerWidth = options.containerWidth;\n var font = options.font;\n var contentWidth = options.contentWidth;\n\n if (!containerWidth) {\n return '';\n }\n\n var lineWidth = getWidth(textLine, font);\n\n if (lineWidth <= containerWidth) {\n return textLine;\n }\n\n for (var j = 0;; j++) {\n if (lineWidth <= contentWidth || j >= options.maxIterations) {\n textLine += options.ellipsis;\n break;\n }\n\n var subLength = j === 0 ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth) : lineWidth > 0 ? Math.floor(textLine.length * contentWidth / lineWidth) : 0;\n textLine = textLine.substr(0, subLength);\n lineWidth = getWidth(textLine, font);\n }\n\n if (textLine === '') {\n textLine = options.placeholder;\n }\n\n return textLine;\n}\n\nfunction estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {\n var width = 0;\n var i = 0;\n\n for (var len = text.length; i < len && width < contentWidth; i++) {\n var charCode = text.charCodeAt(i);\n width += 0 <= charCode && charCode <= 127 ? ascCharWidth : cnCharWidth;\n }\n\n return i;\n}\n\nexport function parsePlainText(text, style) {\n text != null && (text += '');\n var overflow = style.overflow;\n var padding = style.padding;\n var font = style.font;\n var truncate = overflow === 'truncate';\n var calculatedLineHeight = getLineHeight(font);\n var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);\n var bgColorDrawn = !!style.backgroundColor;\n var truncateLineOverflow = style.lineOverflow === 'truncate';\n var width = style.width;\n var lines;\n\n if (width != null && (overflow === 'break' || overflow === 'breakAll')) {\n lines = text ? wrapText(text, style.font, width, overflow === 'breakAll', 0).lines : [];\n } else {\n lines = text ? text.split('\\n') : [];\n }\n\n var contentHeight = lines.length * lineHeight;\n var height = retrieve2(style.height, contentHeight);\n\n if (contentHeight > height && truncateLineOverflow) {\n var lineCount = Math.floor(height / lineHeight);\n lines = lines.slice(0, lineCount);\n }\n\n if (text && truncate && width != null) {\n var options = prepareTruncateOptions(width, font, style.ellipsis, {\n minChar: style.truncateMinChar,\n placeholder: style.placeholder\n });\n\n for (var i = 0; i < lines.length; i++) {\n lines[i] = truncateSingleLine(lines[i], options);\n }\n }\n\n var outerHeight = height;\n var contentWidth = 0;\n\n for (var i = 0; i < lines.length; i++) {\n contentWidth = Math.max(getWidth(lines[i], font), contentWidth);\n }\n\n if (width == null) {\n width = contentWidth;\n }\n\n var outerWidth = contentWidth;\n\n if (padding) {\n outerHeight += padding[0] + padding[2];\n outerWidth += padding[1] + padding[3];\n width += padding[1] + padding[3];\n }\n\n if (bgColorDrawn) {\n outerWidth = width;\n }\n\n return {\n lines: lines,\n height: height,\n outerWidth: outerWidth,\n outerHeight: outerHeight,\n lineHeight: lineHeight,\n calculatedLineHeight: calculatedLineHeight,\n contentWidth: contentWidth,\n contentHeight: contentHeight,\n width: width\n };\n}\n\nvar RichTextToken = function () {\n function RichTextToken() {}\n\n return RichTextToken;\n}();\n\nvar RichTextLine = function () {\n function RichTextLine(tokens) {\n this.tokens = [];\n\n if (tokens) {\n this.tokens = tokens;\n }\n }\n\n return RichTextLine;\n}();\n\nvar RichTextContentBlock = function () {\n function RichTextContentBlock() {\n this.width = 0;\n this.height = 0;\n this.contentWidth = 0;\n this.contentHeight = 0;\n this.outerWidth = 0;\n this.outerHeight = 0;\n this.lines = [];\n }\n\n return RichTextContentBlock;\n}();\n\nexport { RichTextContentBlock };\nexport function parseRichText(text, style) {\n var contentBlock = new RichTextContentBlock();\n text != null && (text += '');\n\n if (!text) {\n return contentBlock;\n }\n\n var topWidth = style.width;\n var topHeight = style.height;\n var overflow = style.overflow;\n var wrapInfo = (overflow === 'break' || overflow === 'breakAll') && topWidth != null ? {\n width: topWidth,\n accumWidth: 0,\n breakAll: overflow === 'breakAll'\n } : null;\n var lastIndex = STYLE_REG.lastIndex = 0;\n var result;\n\n while ((result = STYLE_REG.exec(text)) != null) {\n var matchedIndex = result.index;\n\n if (matchedIndex > lastIndex) {\n pushTokens(contentBlock, text.substring(lastIndex, matchedIndex), style, wrapInfo);\n }\n\n pushTokens(contentBlock, result[2], style, wrapInfo, result[1]);\n lastIndex = STYLE_REG.lastIndex;\n }\n\n if (lastIndex < text.length) {\n pushTokens(contentBlock, text.substring(lastIndex, text.length), style, wrapInfo);\n }\n\n var pendingList = [];\n var calculatedHeight = 0;\n var calculatedWidth = 0;\n var stlPadding = style.padding;\n var truncate = overflow === 'truncate';\n var truncateLine = style.lineOverflow === 'truncate';\n\n function finishLine(line, lineWidth, lineHeight) {\n line.width = lineWidth;\n line.lineHeight = lineHeight;\n calculatedHeight += lineHeight;\n calculatedWidth = Math.max(calculatedWidth, lineWidth);\n }\n\n outer: for (var i = 0; i < contentBlock.lines.length; i++) {\n var line = contentBlock.lines[i];\n var lineHeight = 0;\n var lineWidth = 0;\n\n for (var j = 0; j < line.tokens.length; j++) {\n var token = line.tokens[j];\n var tokenStyle = token.styleName && style.rich[token.styleName] || {};\n var textPadding = token.textPadding = tokenStyle.padding;\n var paddingH = textPadding ? textPadding[1] + textPadding[3] : 0;\n var font = token.font = tokenStyle.font || style.font;\n token.contentHeight = getLineHeight(font);\n var tokenHeight = retrieve2(tokenStyle.height, token.contentHeight);\n token.innerHeight = tokenHeight;\n textPadding && (tokenHeight += textPadding[0] + textPadding[2]);\n token.height = tokenHeight;\n token.lineHeight = retrieve3(tokenStyle.lineHeight, style.lineHeight, tokenHeight);\n token.align = tokenStyle && tokenStyle.align || style.align;\n token.verticalAlign = tokenStyle && tokenStyle.verticalAlign || 'middle';\n\n if (truncateLine && topHeight != null && calculatedHeight + token.lineHeight > topHeight) {\n if (j > 0) {\n line.tokens = line.tokens.slice(0, j);\n finishLine(line, lineWidth, lineHeight);\n contentBlock.lines = contentBlock.lines.slice(0, i + 1);\n } else {\n contentBlock.lines = contentBlock.lines.slice(0, i);\n }\n\n break outer;\n }\n\n var styleTokenWidth = tokenStyle.width;\n var tokenWidthNotSpecified = styleTokenWidth == null || styleTokenWidth === 'auto';\n\n if (typeof styleTokenWidth === 'string' && styleTokenWidth.charAt(styleTokenWidth.length - 1) === '%') {\n token.percentWidth = styleTokenWidth;\n pendingList.push(token);\n token.contentWidth = getWidth(token.text, font);\n } else {\n if (tokenWidthNotSpecified) {\n var textBackgroundColor = tokenStyle.backgroundColor;\n var bgImg = textBackgroundColor && textBackgroundColor.image;\n\n if (bgImg) {\n bgImg = imageHelper.findExistImage(bgImg);\n\n if (imageHelper.isImageReady(bgImg)) {\n token.width = Math.max(token.width, bgImg.width * tokenHeight / bgImg.height);\n }\n }\n }\n\n var remainTruncWidth = truncate && topWidth != null ? topWidth - lineWidth : null;\n\n if (remainTruncWidth != null && remainTruncWidth < token.width) {\n if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {\n token.text = '';\n token.width = token.contentWidth = 0;\n } else {\n token.text = truncateText(token.text, remainTruncWidth - paddingH, font, style.ellipsis, {\n minChar: style.truncateMinChar\n });\n token.width = token.contentWidth = getWidth(token.text, font);\n }\n } else {\n token.contentWidth = getWidth(token.text, font);\n }\n }\n\n token.width += paddingH;\n lineWidth += token.width;\n tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));\n }\n\n finishLine(line, lineWidth, lineHeight);\n }\n\n contentBlock.outerWidth = contentBlock.width = retrieve2(topWidth, calculatedWidth);\n contentBlock.outerHeight = contentBlock.height = retrieve2(topHeight, calculatedHeight);\n contentBlock.contentHeight = calculatedHeight;\n contentBlock.contentWidth = calculatedWidth;\n\n if (stlPadding) {\n contentBlock.outerWidth += stlPadding[1] + stlPadding[3];\n contentBlock.outerHeight += stlPadding[0] + stlPadding[2];\n }\n\n for (var i = 0; i < pendingList.length; i++) {\n var token = pendingList[i];\n var percentWidth = token.percentWidth;\n token.width = parseInt(percentWidth, 10) / 100 * contentBlock.width;\n }\n\n return contentBlock;\n}\n\nfunction pushTokens(block, str, style, wrapInfo, styleName) {\n var isEmptyStr = str === '';\n var tokenStyle = styleName && style.rich[styleName] || {};\n var lines = block.lines;\n var font = tokenStyle.font || style.font;\n var newLine = false;\n var strLines;\n var linesWidths;\n\n if (wrapInfo) {\n var tokenPadding = tokenStyle.padding;\n var tokenPaddingH = tokenPadding ? tokenPadding[1] + tokenPadding[3] : 0;\n\n if (tokenStyle.width != null && tokenStyle.width !== 'auto') {\n var outerWidth_1 = parsePercent(tokenStyle.width, wrapInfo.width) + tokenPaddingH;\n\n if (lines.length > 0) {\n if (outerWidth_1 + wrapInfo.accumWidth > wrapInfo.width) {\n strLines = str.split('\\n');\n newLine = true;\n }\n }\n\n wrapInfo.accumWidth = outerWidth_1;\n } else {\n var res = wrapText(str, font, wrapInfo.width, wrapInfo.breakAll, wrapInfo.accumWidth);\n wrapInfo.accumWidth = res.accumWidth + tokenPaddingH;\n linesWidths = res.linesWidths;\n strLines = res.lines;\n }\n } else {\n strLines = str.split('\\n');\n }\n\n for (var i = 0; i < strLines.length; i++) {\n var text = strLines[i];\n var token = new RichTextToken();\n token.styleName = styleName;\n token.text = text;\n token.isLineHolder = !text && !isEmptyStr;\n\n if (typeof tokenStyle.width === 'number') {\n token.width = tokenStyle.width;\n } else {\n token.width = linesWidths ? linesWidths[i] : getWidth(text, font);\n }\n\n if (!i && !newLine) {\n var tokens = (lines[lines.length - 1] || (lines[0] = new RichTextLine())).tokens;\n var tokensLen = tokens.length;\n tokensLen === 1 && tokens[0].isLineHolder ? tokens[0] = token : (text || !tokensLen || isEmptyStr) && tokens.push(token);\n } else {\n lines.push(new RichTextLine([token]));\n }\n }\n}\n\nfunction isAlphabeticLetter(ch) {\n var code = ch.charCodeAt(0);\n return code >= 0x20 && code <= 0x24F || code >= 0x370 && code <= 0x10FF || code >= 0x1200 && code <= 0x13FF || code >= 0x1E00 && code <= 0x206F;\n}\n\nvar breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {\n obj[ch] = true;\n return obj;\n}, {});\n\nfunction isWordBreakChar(ch) {\n if (isAlphabeticLetter(ch)) {\n if (breakCharMap[ch]) {\n return true;\n }\n\n return false;\n }\n\n return true;\n}\n\nfunction wrapText(text, font, lineWidth, isBreakAll, lastAccumWidth) {\n var lines = [];\n var linesWidths = [];\n var line = '';\n var currentWord = '';\n var currentWordWidth = 0;\n var accumWidth = 0;\n\n for (var i = 0; i < text.length; i++) {\n var ch = text.charAt(i);\n\n if (ch === '\\n') {\n if (currentWord) {\n line += currentWord;\n accumWidth += currentWordWidth;\n }\n\n lines.push(line);\n linesWidths.push(accumWidth);\n line = '';\n currentWord = '';\n currentWordWidth = 0;\n accumWidth = 0;\n continue;\n }\n\n var chWidth = getWidth(ch, font);\n var inWord = isBreakAll ? false : !isWordBreakChar(ch);\n\n if (!lines.length ? lastAccumWidth + accumWidth + chWidth > lineWidth : accumWidth + chWidth > lineWidth) {\n if (!accumWidth) {\n if (inWord) {\n lines.push(currentWord);\n linesWidths.push(currentWordWidth);\n currentWord = ch;\n currentWordWidth = chWidth;\n } else {\n lines.push(ch);\n linesWidths.push(chWidth);\n }\n } else if (line || currentWord) {\n if (inWord) {\n if (!line) {\n line = currentWord;\n currentWord = '';\n currentWordWidth = 0;\n accumWidth = currentWordWidth;\n }\n\n lines.push(line);\n linesWidths.push(accumWidth - currentWordWidth);\n currentWord += ch;\n currentWordWidth += chWidth;\n line = '';\n accumWidth = currentWordWidth;\n } else {\n if (currentWord) {\n line += currentWord;\n currentWord = '';\n currentWordWidth = 0;\n }\n\n lines.push(line);\n linesWidths.push(accumWidth);\n line = ch;\n accumWidth = chWidth;\n }\n }\n\n continue;\n }\n\n accumWidth += chWidth;\n\n if (inWord) {\n currentWord += ch;\n currentWordWidth += chWidth;\n } else {\n if (currentWord) {\n line += currentWord;\n currentWord = '';\n currentWordWidth = 0;\n }\n\n line += ch;\n }\n }\n\n if (!lines.length && !line) {\n line = text;\n currentWord = '';\n currentWordWidth = 0;\n }\n\n if (currentWord) {\n line += currentWord;\n }\n\n if (line) {\n lines.push(line);\n linesWidths.push(accumWidth);\n }\n\n if (lines.length === 1) {\n accumWidth += lastAccumWidth;\n }\n\n return {\n accumWidth: accumWidth,\n lines: lines,\n linesWidths: linesWidths\n };\n}","map":{"version":3,"sources":["D:/Work/WorkSpace/GitWorkSpace/TenShop/resource/ElectronicMall/src啊/ElectronicMallVue/node_modules/zrender/lib/graphic/helper/parseText.js"],"names":["imageHelper","extend","retrieve2","retrieve3","reduce","getLineHeight","getWidth","parsePercent","STYLE_REG","truncateText","text","containerWidth","font","ellipsis","options","textLines","split","prepareTruncateOptions","i","len","length","truncateSingleLine","join","preparedOpts","maxIterations","minChar","cnCharWidth","ascCharWidth","placeholder","contentWidth","Math","max","ellipsisWidth","textLine","lineWidth","j","subLength","estimateLength","floor","substr","width","charCode","charCodeAt","parsePlainText","style","overflow","padding","truncate","calculatedLineHeight","lineHeight","bgColorDrawn","backgroundColor","truncateLineOverflow","lineOverflow","lines","wrapText","contentHeight","height","lineCount","slice","truncateMinChar","outerHeight","outerWidth","RichTextToken","RichTextLine","tokens","RichTextContentBlock","parseRichText","contentBlock","topWidth","topHeight","wrapInfo","accumWidth","breakAll","lastIndex","result","exec","matchedIndex","index","pushTokens","substring","pendingList","calculatedHeight","calculatedWidth","stlPadding","truncateLine","finishLine","line","outer","token","tokenStyle","styleName","rich","textPadding","paddingH","tokenHeight","innerHeight","align","verticalAlign","styleTokenWidth","tokenWidthNotSpecified","charAt","percentWidth","push","textBackgroundColor","bgImg","image","findExistImage","isImageReady","remainTruncWidth","parseInt","block","str","isEmptyStr","newLine","strLines","linesWidths","tokenPadding","tokenPaddingH","outerWidth_1","res","isLineHolder","tokensLen","isAlphabeticLetter","ch","code","breakCharMap","obj","isWordBreakChar","isBreakAll","lastAccumWidth","currentWord","currentWordWidth","chWidth","inWord"],"mappings":";;;;AAAA,OAAO,KAAKA,WAAZ,MAA6B,oBAA7B;AACA,SAASC,MAAT,EAAiBC,SAAjB,EAA4BC,SAA5B,EAAuCC,MAAvC,QAAqD,oBAArD;AACA,SAASC,aAAT,EAAwBC,QAAxB,EAAkCC,YAAlC,QAAsD,uBAAtD;AACA,IAAIC,SAAS,GAAG,+BAAhB;AACA,OAAO,SAASC,YAAT,CAAsBC,IAAtB,EAA4BC,cAA5B,EAA4CC,IAA5C,EAAkDC,QA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AClC,MAAP,IAAiB,CAACmE,IAAtB,EAA4B;AACxBA,IAAAA,IAAI,GAAG7E,IAAP;AACAyH,IAAAA,WAAW,GAAG,EAAd;AACAC,IAAAA,gBAAgB,GAAG,CAAnB;AACH;;AACD,MAAID,WAAJ,EAAiB;AACb5C,IAAAA,IAAI,IAAI4C,WAAR;AACH;;AACD,MAAI5C,IAAJ,EAAU;AACNjC,IAAAA,KAAK,CAACiD,IAAN,CAAWhB,IAAX;AACA6B,IAAAA,WAAW,CAACb,IAAZ,CAAiB/B,UAAjB;AACH;;AACD,MAAIlB,KAAK,CAAClC,MAAN,KAAiB,CAArB,EAAwB;AACpBoD,IAAAA,UAAU,IAAI0D,cAAd;AACH;;AACD,SAAO;AACH1D,IAAAA,UAAU,EAAEA,UADT;AAEHlB,IAAAA,KAAK,EAAEA,KAFJ;AAGH8D,IAAAA,WAAW,EAAEA;AAHV,GAAP;AAKH","sourcesContent":["import * as imageHelper from '../helper/image.js';\nimport { extend, retrieve2, retrieve3, reduce } from '../../core/util.js';\nimport { getLineHeight, getWidth, parsePercent } from '../../contain/text.js';\nvar STYLE_REG = /\\{([a-zA-Z0-9_]+)\\|([^}]*)\\}/g;\nexport function truncateText(text, containerWidth, font, ellipsis, options) {\n if (!containerWidth) {\n return '';\n }\n var textLines = (text + '').split('\\n');\n options = prepareTruncateOptions(containerWidth, font, ellipsis, options);\n for (var i = 0, len = textLines.length; i < len; i++) {\n textLines[i] = truncateSingleLine(textLines[i], options);\n }\n return textLines.join('\\n');\n}\nfunction prepareTruncateOptions(containerWidth, font, ellipsis, options) {\n options = options || {};\n var preparedOpts = extend({}, options);\n preparedOpts.font = font;\n ellipsis = retrieve2(ellipsis, '...');\n preparedOpts.maxIterations = retrieve2(options.maxIterations, 2);\n var minChar = preparedOpts.minChar = retrieve2(options.minChar, 0);\n preparedOpts.cnCharWidth = getWidth('国', font);\n var ascCharWidth = preparedOpts.ascCharWidth = getWidth('a', font);\n preparedOpts.placeholder = retrieve2(options.placeholder, '');\n var contentWidth = containerWidth = Math.max(0, containerWidth - 1);\n for (var i = 0; i < minChar && contentWidth >= ascCharWidth; i++) {\n contentWidth -= ascCharWidth;\n }\n var ellipsisWidth = getWidth(ellipsis, font);\n if (ellipsisWidth > contentWidth) {\n ellipsis = '';\n ellipsisWidth = 0;\n }\n contentWidth = containerWidth - ellipsisWidth;\n preparedOpts.ellipsis = ellipsis;\n preparedOpts.ellipsisWidth = ellipsisWidth;\n preparedOpts.contentWidth = contentWidth;\n preparedOpts.containerWidth = containerWidth;\n return preparedOpts;\n}\nfunction truncateSingleLine(textLine, options) {\n var containerWidth = options.containerWidth;\n var font = options.font;\n var contentWidth = options.contentWidth;\n if (!containerWidth) {\n return '';\n }\n var lineWidth = getWidth(textLine, font);\n if (lineWidth <= containerWidth) {\n return textLine;\n }\n for (var j = 0;; j++) {\n if (lineWidth <= contentWidth || j >= options.maxIterations) {\n textLine += options.ellipsis;\n break;\n }\n var subLength = j === 0\n ? estimateLength(textLine, contentWidth, options.ascCharWidth, options.cnCharWidth)\n : lineWidth > 0\n ? Math.floor(textLine.length * contentWidth / lineWidth)\n : 0;\n textLine = textLine.substr(0, subLength);\n lineWidth = getWidth(textLine, font);\n }\n if (textLine === '') {\n textLine = options.placeholder;\n }\n return textLine;\n}\nfunction estimateLength(text, contentWidth, ascCharWidth, cnCharWidth) {\n var width = 0;\n var i = 0;\n for (var len = text.length; i < len && width < contentWidth; i++) {\n var charCode = text.charCodeAt(i);\n width += (0 <= charCode && charCode <= 127) ? ascCharWidth : cnCharWidth;\n }\n return i;\n}\nexport function parsePlainText(text, style) {\n text != null && (text += '');\n var overflow = style.overflow;\n var padding = style.padding;\n var font = style.font;\n var truncate = overflow === 'truncate';\n var calculatedLineHeight = getLineHeight(font);\n var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);\n var bgColorDrawn = !!(style.backgroundColor);\n var truncateLineOverflow = style.lineOverflow === 'truncate';\n var width = style.width;\n var lines;\n if (width != null && (overflow === 'break' || overflow === 'breakAll')) {\n lines = text ? wrapText(text, style.font, width, overflow === 'breakAll', 0).lines : [];\n }\n else {\n lines = text ? text.split('\\n') : [];\n }\n var contentHeight = lines.length * lineHeight;\n var height = retrieve2(style.height, contentHeight);\n if (contentHeight > height && truncateLineOverflow) {\n var lineCount = Math.floor(height / lineHeight);\n lines = lines.slice(0, lineCount);\n }\n if (text && truncate && width != null) {\n var options = prepareTruncateOptions(width, font, style.ellipsis, {\n minChar: style.truncateMinChar,\n placeholder: style.placeholder\n });\n for (var i = 0; i < lines.length; i++) {\n lines[i] = truncateSingleLine(lines[i], options);\n }\n }\n var outerHeight = height;\n var contentWidth = 0;\n for (var i = 0; i < lines.length; i++) {\n contentWidth = Math.max(getWidth(lines[i], font), contentWidth);\n }\n if (width == null) {\n width = contentWidth;\n }\n var outerWidth = contentWidth;\n if (padding) {\n outerHeight += padding[0] + padding[2];\n outerWidth += padding[1] + padding[3];\n width += padding[1] + padding[3];\n }\n if (bgColorDrawn) {\n outerWidth = width;\n }\n return {\n lines: lines,\n height: height,\n outerWidth: outerWidth,\n outerHeight: outerHeight,\n lineHeight: lineHeight,\n calculatedLineHeight: calculatedLineHeight,\n contentWidth: contentWidth,\n contentHeight: contentHeight,\n width: width\n };\n}\nvar RichTextToken = (function () {\n function RichTextToken() {\n }\n return RichTextToken;\n}());\nvar RichTextLine = (function () {\n function RichTextLine(tokens) {\n this.tokens = [];\n if (tokens) {\n this.tokens = tokens;\n }\n }\n return RichTextLine;\n}());\nvar RichTextContentBlock = (function () {\n function RichTextContentBlock() {\n this.width = 0;\n this.height = 0;\n this.contentWidth = 0;\n this.contentHeight = 0;\n this.outerWidth = 0;\n this.outerHeight = 0;\n this.lines = [];\n }\n return RichTextContentBlock;\n}());\nexport { RichTextContentBlock };\nexport function parseRichText(text, style) {\n var contentBlock = new RichTextContentBlock();\n text != null && (text += '');\n if (!text) {\n return contentBlock;\n }\n var topWidth = style.width;\n var topHeight = style.height;\n var overflow = style.overflow;\n var wrapInfo = (overflow === 'break' || overflow === 'breakAll') && topWidth != null\n ? { width: topWidth, accumWidth: 0, breakAll: overflow === 'breakAll' }\n : null;\n var lastIndex = STYLE_REG.lastIndex = 0;\n var result;\n while ((result = STYLE_REG.exec(text)) != null) {\n var matchedIndex = result.index;\n if (matchedIndex > lastIndex) {\n pushTokens(contentBlock, text.substring(lastIndex, matchedIndex), style, wrapInfo);\n }\n pushTokens(contentBlock, result[2], style, wrapInfo, result[1]);\n lastIndex = STYLE_REG.lastIndex;\n }\n if (lastIndex < text.length) {\n pushTokens(contentBlock, text.substring(lastIndex, text.length), style, wrapInfo);\n }\n var pendingList = [];\n var calculatedHeight = 0;\n var calculatedWidth = 0;\n var stlPadding = style.padding;\n var truncate = overflow === 'truncate';\n var truncateLine = style.lineOverflow === 'truncate';\n function finishLine(line, lineWidth, lineHeight) {\n line.width = lineWidth;\n line.lineHeight = lineHeight;\n calculatedHeight += lineHeight;\n calculatedWidth = Math.max(calculatedWidth, lineWidth);\n }\n outer: for (var i = 0; i < contentBlock.lines.length; i++) {\n var line = contentBlock.lines[i];\n var lineHeight = 0;\n var lineWidth = 0;\n for (var j = 0; j < line.tokens.length; j++) {\n var token = line.tokens[j];\n var tokenStyle = token.styleName && style.rich[token.styleName] || {};\n var textPadding = token.textPadding = tokenStyle.padding;\n var paddingH = textPadding ? textPadding[1] + textPadding[3] : 0;\n var font = token.font = tokenStyle.font || style.font;\n token.contentHeight = getLineHeight(font);\n var tokenHeight = retrieve2(tokenStyle.height, token.contentHeight);\n token.innerHeight = tokenHeight;\n textPadding && (tokenHeight += textPadding[0] + textPadding[2]);\n token.height = tokenHeight;\n token.lineHeight = retrieve3(tokenStyle.lineHeight, style.lineHeight, tokenHeight);\n token.align = tokenStyle && tokenStyle.align || style.align;\n token.verticalAlign = tokenStyle && tokenStyle.verticalAlign || 'middle';\n if (truncateLine && topHeight != null && calculatedHeight + token.lineHeight > topHeight) {\n if (j > 0) {\n line.tokens = line.tokens.slice(0, j);\n finishLine(line, lineWidth, lineHeight);\n contentBlock.lines = contentBlock.lines.slice(0, i + 1);\n }\n else {\n contentBlock.lines = contentBlock.lines.slice(0, i);\n }\n break outer;\n }\n var styleTokenWidth = tokenStyle.width;\n var tokenWidthNotSpecified = styleTokenWidth == null || styleTokenWidth === 'auto';\n if (typeof styleTokenWidth === 'string' && styleTokenWidth.charAt(styleTokenWidth.length - 1) === '%') {\n token.percentWidth = styleTokenWidth;\n pendingList.push(token);\n token.contentWidth = getWidth(token.text, font);\n }\n else {\n if (tokenWidthNotSpecified) {\n var textBackgroundColor = tokenStyle.backgroundColor;\n var bgImg = textBackgroundColor && textBackgroundColor.image;\n if (bgImg) {\n bgImg = imageHelper.findExistImage(bgImg);\n if (imageHelper.isImageReady(bgImg)) {\n token.width = Math.max(token.width, bgImg.width * tokenHeight / bgImg.height);\n }\n }\n }\n var remainTruncWidth = truncate && topWidth != null\n ? topWidth - lineWidth : null;\n if (remainTruncWidth != null && remainTruncWidth < token.width) {\n if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {\n token.text = '';\n token.width = token.contentWidth = 0;\n }\n else {\n token.text = truncateText(token.text, remainTruncWidth - paddingH, font, style.ellipsis, { minChar: style.truncateMinChar });\n token.width = token.contentWidth = getWidth(token.text, font);\n }\n }\n else {\n token.contentWidth = getWidth(token.text, font);\n }\n }\n token.width += paddingH;\n lineWidth += token.width;\n tokenStyle && (lineHeight = Math.max(lineHeight, token.lineHeight));\n }\n finishLine(line, lineWidth, lineHeight);\n }\n contentBlock.outerWidth = contentBlock.width = retrieve2(topWidth, calculatedWidth);\n contentBlock.outerHeight = contentBlock.height = retrieve2(topHeight, calculatedHeight);\n contentBlock.contentHeight = calculatedHeight;\n contentBlock.contentWidth = calculatedWidth;\n if (stlPadding) {\n contentBlock.outerWidth += stlPadding[1] + stlPadding[3];\n contentBlock.outerHeight += stlPadding[0] + stlPadding[2];\n }\n for (var i = 0; i < pendingList.length; i++) {\n var token = pendingList[i];\n var percentWidth = token.percentWidth;\n token.width = parseInt(percentWidth, 10) / 100 * contentBlock.width;\n }\n return contentBlock;\n}\nfunction pushTokens(block, str, style, wrapInfo, styleName) {\n var isEmptyStr = str === '';\n var tokenStyle = styleName && style.rich[styleName] || {};\n var lines = block.lines;\n var font = tokenStyle.font || style.font;\n var newLine = false;\n var strLines;\n var linesWidths;\n if (wrapInfo) {\n var tokenPadding = tokenStyle.padding;\n var tokenPaddingH = tokenPadding ? tokenPadding[1] + tokenPadding[3] : 0;\n if (tokenStyle.width != null && tokenStyle.width !== 'auto') {\n var outerWidth_1 = parsePercent(tokenStyle.width, wrapInfo.width) + tokenPaddingH;\n if (lines.length > 0) {\n if (outerWidth_1 + wrapInfo.accumWidth > wrapInfo.width) {\n strLines = str.split('\\n');\n newLine = true;\n }\n }\n wrapInfo.accumWidth = outerWidth_1;\n }\n else {\n var res = wrapText(str, font, wrapInfo.width, wrapInfo.breakAll, wrapInfo.accumWidth);\n wrapInfo.accumWidth = res.accumWidth + tokenPaddingH;\n linesWidths = res.linesWidths;\n strLines = res.lines;\n }\n }\n else {\n strLines = str.split('\\n');\n }\n for (var i = 0; i < strLines.length; i++) {\n var text = strLines[i];\n var token = new RichTextToken();\n token.styleName = styleName;\n token.text = text;\n token.isLineHolder = !text && !isEmptyStr;\n if (typeof tokenStyle.width === 'number') {\n token.width = tokenStyle.width;\n }\n else {\n token.width = linesWidths\n ? linesWidths[i]\n : getWidth(text, font);\n }\n if (!i && !newLine) {\n var tokens = (lines[lines.length - 1] || (lines[0] = new RichTextLine())).tokens;\n var tokensLen = tokens.length;\n (tokensLen === 1 && tokens[0].isLineHolder)\n ? (tokens[0] = token)\n : ((text || !tokensLen || isEmptyStr) && tokens.push(token));\n }\n else {\n lines.push(new RichTextLine([token]));\n }\n }\n}\nfunction isAlphabeticLetter(ch) {\n var code = ch.charCodeAt(0);\n return code >= 0x20 && code <= 0x24F\n || code >= 0x370 && code <= 0x10FF\n || code >= 0x1200 && code <= 0x13FF\n || code >= 0x1E00 && code <= 0x206F;\n}\nvar breakCharMap = reduce(',&?/;] '.split(''), function (obj, ch) {\n obj[ch] = true;\n return obj;\n}, {});\nfunction isWordBreakChar(ch) {\n if (isAlphabeticLetter(ch)) {\n if (breakCharMap[ch]) {\n return true;\n }\n return false;\n }\n return true;\n}\nfunction wrapText(text, font, lineWidth, isBreakAll, lastAccumWidth) {\n var lines = [];\n var linesWidths = [];\n var line = '';\n var currentWord = '';\n var currentWordWidth = 0;\n var accumWidth = 0;\n for (var i = 0; i < text.length; i++) {\n var ch = text.charAt(i);\n if (ch === '\\n') {\n if (currentWord) {\n line += currentWord;\n accumWidth += currentWordWidth;\n }\n lines.push(line);\n linesWidths.push(accumWidth);\n line = '';\n currentWord = '';\n currentWordWidth = 0;\n accumWidth = 0;\n continue;\n }\n var chWidth = getWidth(ch, font);\n var inWord = isBreakAll ? false : !isWordBreakChar(ch);\n if (!lines.length\n ? lastAccumWidth + accumWidth + chWidth > lineWidth\n : accumWidth + chWidth > lineWidth) {\n if (!accumWidth) {\n if (inWord) {\n lines.push(currentWord);\n linesWidths.push(currentWordWidth);\n currentWord = ch;\n currentWordWidth = chWidth;\n }\n else {\n lines.push(ch);\n linesWidths.push(chWidth);\n }\n }\n else if (line || currentWord) {\n if (inWord) {\n if (!line) {\n line = currentWord;\n currentWord = '';\n currentWordWidth = 0;\n accumWidth = currentWordWidth;\n }\n lines.push(line);\n linesWidths.push(accumWidth - currentWordWidth);\n currentWord += ch;\n currentWordWidth += chWidth;\n line = '';\n accumWidth = currentWordWidth;\n }\n else {\n if (currentWord) {\n line += currentWord;\n currentWord = '';\n currentWordWidth = 0;\n }\n lines.push(line);\n linesWidths.push(accumWidth);\n line = ch;\n accumWidth = chWidth;\n }\n }\n continue;\n }\n accumWidth += chWidth;\n if (inWord) {\n currentWord += ch;\n currentWordWidth += chWidth;\n }\n else {\n if (currentWord) {\n line += currentWord;\n currentWord = '';\n currentWordWidth = 0;\n }\n line += ch;\n }\n }\n if (!lines.length && !line) {\n line = text;\n currentWord = '';\n currentWordWidth = 0;\n }\n if (currentWord) {\n line += currentWord;\n }\n if (line) {\n lines.push(line);\n linesWidths.push(accumWidth);\n }\n if (lines.length === 1) {\n accumWidth += lastAccumWidth;\n }\n return {\n accumWidth: accumWidth,\n lines: lines,\n linesWidths: linesWidths\n };\n}\n"]},"metadata":{},"sourceType":"module"} |