Merge branch 'master' into dev

This commit is contained in:
Nick O'Leary
2021-07-16 08:53:35 +01:00
4 changed files with 8 additions and 6 deletions

View File

@@ -2369,6 +2369,7 @@ RED.view = (function() {
var textDimensionPlaceholder = {};
var textDimensionCache = {};
function calculateTextDimensions(str,className) {
var cacheKey = "!"+str;
if (!textDimensionPlaceholder[className]) {
textDimensionPlaceholder[className] = document.createElement("span");
textDimensionPlaceholder[className].className = className;
@@ -2377,15 +2378,15 @@ RED.view = (function() {
document.getElementById("red-ui-editor").appendChild(textDimensionPlaceholder[className]);
textDimensionCache[className] = {};
} else {
if (textDimensionCache[className][str]) {
return textDimensionCache[className][str]
if (textDimensionCache[className][cacheKey]) {
return textDimensionCache[className][cacheKey]
}
}
textDimensionPlaceholder[className].textContent = (str||"");
var w = textDimensionPlaceholder[className].offsetWidth;
var h = textDimensionPlaceholder[className].offsetHeight;
textDimensionCache[className][str] = [w,h];
return textDimensionCache[className][str];
textDimensionCache[className][cacheKey] = [w,h];
return textDimensionCache[className][cacheKey];
}
function convertLineBreakCharacter(str) {