MCPcopy Index your code
hub / github.com/SuperMap/iClient-JavaScript / pushTokens

Function pushTokens

libs/echarts/echarts.simple.js:8225–8262  ·  view source on GitHub ↗
(block, str, styleName)

Source from the content-addressed store, hash-verified

8223}
8224
8225function pushTokens(block, str, styleName) {
8226 var isEmptyStr = str === '';
8227 var strs = str.split('\n');
8228 var lines = block.lines;
8229
8230 for (var i = 0; i < strs.length; i++) {
8231 var text = strs[i];
8232 var token = {
8233 styleName: styleName,
8234 text: text,
8235 isLineHolder: !text && !isEmptyStr
8236 };
8237
8238 // The first token should be appended to the last line.
8239 if (!i) {
8240 var tokens = (lines[lines.length - 1] || (lines[0] = {tokens: []})).tokens;
8241
8242 // Consider cases:
8243 // (1) ''.split('\n') => ['', '\n', ''], the '' at the first item
8244 // (which is a placeholder) should be replaced by new token.
8245 // (2) A image backage, where token likes {a|}.
8246 // (3) A redundant '' will affect textAlign in line.
8247 // (4) tokens with the same tplName should not be merged, because
8248 // they should be displayed in different box (with border and padding).
8249 var tokensLen = tokens.length;
8250 (tokensLen === 1 && tokens[0].isLineHolder)
8251 ? (tokens[0] = token)
8252 // Consider text is '', only insert when it is the "lineHolder" or
8253 // "emptyStr". Otherwise a redundant '' will affect textAlign in line.
8254 : ((text || !tokensLen || isEmptyStr) && tokens.push(token));
8255 }
8256 // Other tokens always start a new line.
8257 else {
8258 // If there is '', insert it as a placeholder.
8259 lines.push({tokens: [token]});
8260 }
8261 }
8262}
8263
8264function makeFont(style) {
8265 // FIXME in node-canvas fontWeight is before fontStyle

Callers 1

parseRichTextFunction · 0.70

Calls 1

pushMethod · 0.80

Tested by

no test coverage detected