12.3.0 release

This commit is contained in:
Gaudenz Alder 2019-11-25 11:35:34 +01:00
parent cd91500da0
commit f6b84673b0
14 changed files with 1797 additions and 1688 deletions

View file

@ -1,3 +1,8 @@
25-NOV-2019: 12.3.0
- Fixes client-side math export in Firefox
- Uses mxGraph 4.0.6 beta 7
21-NOV-2019: 12.2.9
- Fixes autosize for font size and style changes

View file

@ -1 +1 @@
12.2.9
12.3.0

View file

@ -331,15 +331,16 @@ mxSvgCanvas2D.prototype.updateText=function(a,b,c,d,e,f,g,k,l,m,n){if(null!=n&&n
"px"));g&&0<c&&(q.style.width=Math.round(c+1)+"px");var t,u=q;null!=u.firstChild&&"DIV"==u.firstChild.nodeName&&(u=u.firstChild);var x=null!=n.mxCachedOffsetWidth?n.mxCachedOffsetWidth:u.offsetWidth;t=x+0;g&&"fill"!=k&&(l&&(t=Math.min(t,c)),q.style.width=Math.round(t+1)+"px");t=null!=n.mxCachedFinalOffsetWidth?n.mxCachedFinalOffsetWidth:u.offsetWidth;g=null!=n.mxCachedFinalOffsetHeight?n.mxCachedFinalOffsetHeight:u.offsetHeight;this.cacheOffsetSize&&(n.mxCachedOffsetWidth=x,n.mxCachedFinalOffsetWidth=
t,n.mxCachedFinalOffsetHeight=g);t+=0;g-=2;l&&(g=Math.min(g,d),t=Math.min(t,c));"width"==k?d=g:"fill"!=k&&(c=t,d=g);g=l=0;e==mxConstants.ALIGN_CENTER?l-=c/2:e==mxConstants.ALIGN_RIGHT&&(l-=c);a+=l;f==mxConstants.ALIGN_MIDDLE?g-=d/2:f==mxConstants.ALIGN_BOTTOM&&(g-=d);"fill"!=k&&mxClient.IS_FF&&mxClient.IS_WIN&&(g-=2);b+=g;e=1!=r.scale?"scale("+r.scale+")":"";0!=r.rotation&&this.rotateHtml?(e+="rotate("+r.rotation+","+c/2+","+d/2+")",b=this.rotatePoint((a+c/2)*r.scale,(b+d/2)*r.scale,r.rotation,r.rotationCx,
r.rotationCy),a=b.x-c*r.scale/2,b=b.y-d*r.scale/2):(a*=r.scale,b*=r.scale);0!=m&&(e+="rotate("+m+","+-l+","+-g+")");n.setAttribute("transform","translate("+Math.round(a)+","+Math.round(b)+")"+e);p.setAttribute("width",Math.round(Math.max(1,c)));p.setAttribute("height",Math.round(Math.max(1,d)))}};
mxSvgCanvas2D.prototype.text=function(a,b,c,d,e,f,g,k,l,m,n,p,q){if(this.textEnabled&&null!=e){p=null!=p?p:0;var r=this.state;a+=r.dx;b+=r.dy;if(this.foEnabled&&"html"==l){var t="vertical-align:top;";n?t+="overflow:hidden;max-height:"+Math.round(d)+"px;max-width:"+Math.round(c)+"px;":"fill"==m?t+="width:"+Math.round(c+1)+"px;height:"+Math.round(d+1)+"px;overflow:hidden;":"width"==m&&(t+="width:"+Math.round(c+1)+"px;",0<d&&(t+="max-height:"+Math.round(d)+"px;overflow:hidden;"));var t=k&&0<c?t+("width:"+
Math.round(c+1)+"px;white-space:normal;word-wrap:"+mxConstants.WORD_WRAP+";"):t+"white-space:nowrap;",u=this.createElement("g");1>r.alpha&&u.setAttribute("opacity",r.alpha);var x=this.createElement("foreignObject");x.setAttribute("style","overflow:visible;");x.setAttribute("pointer-events",this.pointerEvents?this.pointerEventsValue:"none");t=this.createDiv(e,f,g,t,m,k&&0<c?"normal":null);if(null!=t){null!=q&&t.setAttribute("dir",q);u.appendChild(x);this.root.appendChild(u);var y,A;q=y=2;if(!mxClient.IS_IE||
9!=document.documentMode&&mxClient.IS_SVG){this.root.ownerDocument!=document?(t.style.visibility="hidden",document.body.appendChild(t)):x.appendChild(t);var z=t;null!=z.firstChild&&"DIV"==z.firstChild.nodeName&&(z=z.firstChild,k&&"break-word"==t.style.wordWrap&&(z.style.width="100%"));v=z.offsetWidth;0==v&&t.parentNode==x&&(t.style.visibility="hidden",document.body.appendChild(t),v=z.offsetWidth);this.cacheOffsetSize&&(u.mxCachedOffsetWidth=v);!n&&k&&0<c&&this.root.ownerDocument!=document&&"fill"!=
m&&"width"!=m&&(B=t.style.whiteSpace,t.style.whiteSpace="nowrap",v<z.offsetWidth&&(t.style.whiteSpace=B));y=v+y-1;k&&"fill"!=m&&"width"!=m&&(n&&(y=Math.min(y,c)),t.style.width=y+"px");y=z.offsetWidth;A=z.offsetHeight;this.cacheOffsetSize&&(u.mxCachedFinalOffsetWidth=y,u.mxCachedFinalOffsetHeight=A);A-=q;t.parentNode!=x&&(x.appendChild(t),t.style.visibility="")}else{z=document.createElement("div");z.style.cssText=t.getAttribute("style");z.style.display=mxClient.IS_QUIRKS?"inline":"inline-block";z.style.position=
"absolute";z.style.visibility="hidden";A=document.createElement("div");A.style.display=mxClient.IS_QUIRKS?"inline":"inline-block";A.style.wordWrap=mxConstants.WORD_WRAP;A.innerHTML=mxUtils.isNode(e)?e.outerHTML:e;z.appendChild(A);document.body.appendChild(z);8!=document.documentMode&&9!=document.documentMode&&null!=r.fontBorderColor&&(y+=2,q+=2);if(k&&0<c){var v=A.offsetWidth;padDx=0;if(!n&&k&&0<c&&this.root.ownerDocument!=document&&"fill"!=m){var B=z.style.whiteSpace;A.style.whiteSpace="nowrap";
v<A.offsetWidth&&(z.style.whiteSpace=B)}n&&(v=Math.min(v,c));z.style.width=v+"px";y=A.offsetWidth+y+padDx;A=A.offsetHeight+q;z.style.display="inline-block";z.style.position="";z.style.visibility="";z.style.width=y+"px";t.setAttribute("style",z.style.cssText)}else y=A.offsetWidth+y,A=A.offsetHeight+q;z.parentNode.removeChild(z);x.appendChild(t)}n&&(A=Math.min(A,d),y=Math.min(y,c));"width"==m?d=A:"fill"!=m&&(c=y,d=A);1>r.alpha&&u.setAttribute("opacity",r.alpha);q=t=0;f==mxConstants.ALIGN_CENTER?t-=
c/2:f==mxConstants.ALIGN_RIGHT&&(t-=c);a+=t;g==mxConstants.ALIGN_MIDDLE?q-=d/2:g==mxConstants.ALIGN_BOTTOM&&(q-=d);"fill"!=m&&mxClient.IS_FF&&mxClient.IS_WIN&&(q-=2);b+=q;z=1!=r.scale?"scale("+r.scale+")":"";0!=r.rotation&&this.rotateHtml?(z+="rotate("+r.rotation+","+c/2+","+d/2+")",b=this.rotatePoint((a+c/2)*r.scale,(b+d/2)*r.scale,r.rotation,r.rotationCx,r.rotationCy),a=b.x-c*r.scale/2,b=b.y-d*r.scale/2):(a*=r.scale,b*=r.scale);0!=p&&(z+="rotate("+p+","+-t+","+-q+")");u.setAttribute("transform",
"translate("+(Math.round(a)+this.foOffset)+","+(Math.round(b)+this.foOffset)+")"+z);x.setAttribute("width",Math.round(Math.max(1,c)));x.setAttribute("height",Math.round(Math.max(1,d)));this.root.ownerDocument!=document&&(a=this.createAlternateContent(x,a,b,c,d,e,f,g,k,l,m,n,p),null!=a&&(x.setAttribute("requiredFeatures","http://www.w3.org/TR/SVG11/feature#Extensibility"),c=this.createElement("switch"),c.appendChild(x),c.appendChild(a),u.appendChild(c)))}}else this.plainText(a,b,c,d,e,f,g,k,m,n,p,
q)}};mxSvgCanvas2D.prototype.createClip=function(a,b,c,d){a=Math.round(a);b=Math.round(b);c=Math.round(c);d=Math.round(d);for(var e="mx-clip-"+a+"-"+b+"-"+c+"-"+d,f=0,g=e+"-"+f;null!=document.getElementById(g);)g=e+"-"+ ++f;clip=this.createElement("clipPath");clip.setAttribute("id",g);e=this.createElement("rect");e.setAttribute("x",a);e.setAttribute("y",b);e.setAttribute("width",c);e.setAttribute("height",d);clip.appendChild(e);return clip};
mxSvgCanvas2D.prototype.addForeignObject=function(a,b,c,d,e,f,g,k,l,m,n,p,q,r,t){var u=this.state;q=this.createElement("g");1>u.alpha&&q.setAttribute("opacity",u.alpha);var x=this.createElement("foreignObject");x.setAttribute("style","overflow:visible;");x.setAttribute("pointer-events",this.pointerEvents?this.pointerEventsValue:"none");q.appendChild(x);t.appendChild(q);var y,A;t=y=2;if(!mxClient.IS_IE||9!=document.documentMode&&mxClient.IS_SVG){this.root.ownerDocument!=document?(r.style.visibility=
"hidden",document.body.appendChild(r)):x.appendChild(r);var z=r;null!=z.firstChild&&"DIV"==z.firstChild.nodeName&&(z=z.firstChild,k&&"break-word"==r.style.wordWrap&&(z.style.width="100%"));v=z.offsetWidth;0==v&&r.parentNode==x&&(r.style.visibility="hidden",document.body.appendChild(r),v=z.offsetWidth);this.cacheOffsetSize&&(q.mxCachedOffsetWidth=v);!n&&k&&0<c&&this.root.ownerDocument!=document&&"fill"!=m&&"width"!=m&&(B=r.style.whiteSpace,r.style.whiteSpace="nowrap",v<z.offsetWidth&&(r.style.whiteSpace=
B));y=v+y-1;k&&"fill"!=m&&"width"!=m&&(n&&(y=Math.min(y,c)),r.style.width=y+"px");y=z.offsetWidth;A=z.offsetHeight;this.cacheOffsetSize&&(q.mxCachedFinalOffsetWidth=y,q.mxCachedFinalOffsetHeight=A);A-=t;r.parentNode!=x&&(x.appendChild(r),r.style.visibility="")}else{z=document.createElement("div");z.style.cssText=r.getAttribute("style");z.style.display=mxClient.IS_QUIRKS?"inline":"inline-block";z.style.position="absolute";z.style.visibility="hidden";A=document.createElement("div");A.style.display=
mxClient.IS_QUIRKS?"inline":"inline-block";A.style.wordWrap=mxConstants.WORD_WRAP;A.innerHTML=mxUtils.isNode(e)?e.outerHTML:e;z.appendChild(A);document.body.appendChild(z);8!=document.documentMode&&9!=document.documentMode&&null!=u.fontBorderColor&&(y+=2,t+=2);if(k&&0<c){var v=A.offsetWidth;padDx=0;if(!n&&k&&0<c&&this.root.ownerDocument!=document&&"fill"!=m){var B=z.style.whiteSpace;A.style.whiteSpace="nowrap";v<A.offsetWidth&&(z.style.whiteSpace=B)}n&&(v=Math.min(v,c));z.style.width=v+"px";y=A.offsetWidth+
y+padDx;A=A.offsetHeight+t;z.style.display="inline-block";z.style.position="";z.style.visibility="";z.style.width=y+"px";r.setAttribute("style",z.style.cssText)}else y=A.offsetWidth+y,A=A.offsetHeight+t;z.parentNode.removeChild(z);x.appendChild(r)}n&&(A=Math.min(A,d),y=Math.min(y,c));"width"==m?d=A:"fill"!=m&&(c=y,d=A);1>u.alpha&&q.setAttribute("opacity",u.alpha);t=r=0;f==mxConstants.ALIGN_CENTER?r-=c/2:f==mxConstants.ALIGN_RIGHT&&(r-=c);a+=r;g==mxConstants.ALIGN_MIDDLE?t-=d/2:g==mxConstants.ALIGN_BOTTOM&&
(t-=d);"fill"!=m&&mxClient.IS_FF&&mxClient.IS_WIN&&(t-=2);b+=t;z=1!=u.scale?"scale("+u.scale+")":"";0!=u.rotation&&this.rotateHtml?(z+="rotate("+u.rotation+","+c/2+","+d/2+")",b=this.rotatePoint((a+c/2)*u.scale,(b+d/2)*u.scale,u.rotation,u.rotationCx,u.rotationCy),a=b.x-c*u.scale/2,b=b.y-d*u.scale/2):(a*=u.scale,b*=u.scale);0!=p&&(z+="rotate("+p+","+-r+","+-t+")");q.setAttribute("transform","translate("+(Math.round(a)+this.foOffset)+","+(Math.round(b)+this.foOffset)+")"+z);x.setAttribute("width",
Math.round(Math.max(1,c)));x.setAttribute("height",Math.round(Math.max(1,d)));this.root.ownerDocument!=document&&(a=this.createAlternateContent(x,a,b,c,d,e,f,g,k,l,m,n,p),null!=a&&(x.setAttribute("requiredFeatures","http://www.w3.org/TR/SVG11/feature#Extensibility"),c=this.createElement("switch"),c.appendChild(x),c.appendChild(a),q.appendChild(c)))};
mxSvgCanvas2D.prototype.text=function(a,b,c,d,e,f,g,k,l,m,n,p,q){if(this.textEnabled&&null!=e){p=null!=p?p:0;var r=this.state;a+=r.dx;b+=r.dy;this.foEnabled&&"html"==l?(r="vertical-align:top;",n?r+="overflow:hidden;max-height:"+Math.round(d)+"px;max-width:"+Math.round(c)+"px;":"fill"==m?r+="width:"+Math.round(c+1)+"px;height:"+Math.round(d+1)+"px;overflow:hidden;":"width"==m&&(r+="width:"+Math.round(c+1)+"px;",0<d&&(r+="max-height:"+Math.round(d)+"px;overflow:hidden;")),r=k&&0<c?r+("width:"+Math.round(c+
1)+"px;white-space:normal;word-wrap:"+mxConstants.WORD_WRAP+";"):r+"white-space:nowrap;",r=this.createDiv(e,f,g,r,m,k&&0<c?"normal":null),null!=r&&(null!=q&&r.setAttribute("dir",q),this.addForeignObject(a,b,c,d,e,f,g,k,l,m,n,p,q,r,this.root))):this.plainText(a,b,c,d,e,f,g,k,m,n,p,q)}};
mxSvgCanvas2D.prototype.createClip=function(a,b,c,d){a=Math.round(a);b=Math.round(b);c=Math.round(c);d=Math.round(d);for(var e="mx-clip-"+a+"-"+b+"-"+c+"-"+d,f=0,g=e+"-"+f;null!=document.getElementById(g);)g=e+"-"+ ++f;clip=this.createElement("clipPath");clip.setAttribute("id",g);e=this.createElement("rect");e.setAttribute("x",a);e.setAttribute("y",b);e.setAttribute("width",c);e.setAttribute("height",d);clip.appendChild(e);return clip};
mxSvgCanvas2D.prototype.plainText=function(a,b,c,d,e,f,g,k,l,m,n,p){n=null!=n?n:0;k=this.state;var q=k.fontSize,r=this.createElement("g"),t=k.transform||"";this.updateFont(r);0!=n&&(t+="rotate("+n+","+this.format(a*k.scale)+","+this.format(b*k.scale)+")");null!=p&&r.setAttribute("direction",p);m&&0<c&&0<d&&(p=a,n=b,f==mxConstants.ALIGN_CENTER?p-=c/2:f==mxConstants.ALIGN_RIGHT&&(p-=c),"fill"!=l&&(g==mxConstants.ALIGN_MIDDLE?n-=d/2:g==mxConstants.ALIGN_BOTTOM&&(n-=d)),n=this.createClip(p*k.scale-2,
n*k.scale-2,c*k.scale+4,d*k.scale+4),null!=this.defs?this.defs.appendChild(n):this.root.appendChild(n),mxClient.IS_CHROMEAPP||mxClient.IS_IE||mxClient.IS_IE11||mxClient.IS_EDGE||this.root.ownerDocument!=document?r.setAttribute("clip-path","url(#"+n.getAttribute("id")+")"):(p=this.getBaseUrl().replace(/([\(\)])/g,"\\$1"),r.setAttribute("clip-path","url("+p+"#"+n.getAttribute("id")+")")));n=f==mxConstants.ALIGN_RIGHT?"end":f==mxConstants.ALIGN_CENTER?"middle":"start";"start"!=n&&r.setAttribute("text-anchor",
n);this.styleEnabled&&q==mxConstants.DEFAULT_FONTSIZE||r.setAttribute("font-size",q*k.scale+"px");0<t.length&&r.setAttribute("transform",t);1>k.alpha&&r.setAttribute("opacity",k.alpha);t=e.split("\n");p=Math.round(q*mxConstants.LINE_HEIGHT);var u=q+(t.length-1)*p;n=b+q-1;g==mxConstants.ALIGN_MIDDLE?"fill"==l?n-=d/2:(m=(this.matchHtmlAlignment&&m&&0<d?Math.min(u,d):u)/2,n-=m+1):g==mxConstants.ALIGN_BOTTOM&&("fill"==l?n-=d:(m=this.matchHtmlAlignment&&m&&0<d?Math.min(u,d):u,n-=m+2));for(m=0;m<t.length;m++)0<

View file

@ -1,7 +1,7 @@
CACHE MANIFEST
# THIS FILE WAS GENERATED. DO NOT MODIFY!
# 11/21/2019 10:50 PM
# 11/25/2019 11:19 AM
app.html
index.html?offline=1

View file

@ -225,65 +225,66 @@
// Waits for MathJax.Hub to become available to register
// wait counter callback asynchronously after math render
var editorDoMathJaxRender = Editor.doMathJaxRender;
// FIXME: Transforms ignored
// var editorDoMathJaxRender = Editor.doMathJaxRender;
Editor.doMathJaxRender = function(container)
{
editorDoMathJaxRender.apply(this, arguments);
// Editor.doMathJaxRender = function(container)
// {
// editorDoMathJaxRender.apply(this, arguments);
window.setTimeout(function()
{
window.MathJax.Hub.Queue(function ()
{
// Wraps all text labels in SVG foreignObjects to avoid
// Chrome changing offset for textboxes near page border
var pages = document.querySelectorAll('[id^=mxPage]');
// window.setTimeout(function()
// {
// window.MathJax.Hub.Queue(function ()
// {
// // Wraps all text labels in SVG foreignObjects to avoid
// // Chrome changing offset for textboxes near page border
// var pages = document.querySelectorAll('[id^=mxPage]');
for (var i = 0; i < pages.length; i++)
{
var page = pages[i];
var svg = page.getElementsByTagName('svg')[0];
var divs = page.getElementsByTagName('div');
var snap = [];
// for (var i = 0; i < pages.length; i++)
// {
// var page = pages[i];
// var svg = page.getElementsByTagName('svg')[0];
// var divs = page.getElementsByTagName('div');
// var snap = [];
for (var j = 0; j < divs.length; j++)
{
if (divs[j].parentNode == svg.parentNode)
{
snap.push(divs[j]);
}
}
// for (var j = 0; j < divs.length; j++)
// {
// if (divs[j].parentNode == svg.parentNode)
// {
// snap.push(divs[j]);
// }
// }
var top = svg.parentNode.getBoundingClientRect();
// var top = svg.parentNode.getBoundingClientRect();
for (var j = 0; j < snap.length; j++)
{
if (snap[j].parentNode == svg.parentNode)
{
var fo = svg.ownerDocument.createElementNS(mxConstants.NS_SVG, 'foreignObject');
var rect = snap[j].getBoundingClientRect();
// for (var j = 0; j < snap.length; j++)
// {
// if (snap[j].parentNode == svg.parentNode)
// {
// var fo = svg.ownerDocument.createElementNS(mxConstants.NS_SVG, 'foreignObject');
// var rect = snap[j].getBoundingClientRect();
// Sets position on foreignObject
fo.setAttribute('x', rect.x);
fo.setAttribute('y', rect.y - top.y);
fo.setAttribute('width', rect.width);
fo.setAttribute('height', rect.height);
// // Sets position on foreignObject
// fo.setAttribute('x', rect.x);
// fo.setAttribute('y', rect.y - top.y);
// fo.setAttribute('width', rect.width);
// fo.setAttribute('height', rect.height);
// Resets position on inner DIV
snap[j].style.top = '0px';
snap[j].style.left = '0px';
snap[j].style.transform = '';
// // Resets position on inner DIV
// snap[j].style.top = '0px';
// snap[j].style.left = '0px';
// snap[j].style.transform = '';
fo.appendChild(snap[j]);
svg.appendChild(fo);
}
}
}
// fo.appendChild(snap[j]);
// svg.appendChild(fo);
// }
// }
// }
decrementWaitCounter();
});
}, 0);
};
// decrementWaitCounter();
// });
// }, 0);
// };
// Adds async MathJax rendering task
function renderMath(elt)

File diff suppressed because one or more lines are too long

View file

@ -1541,10 +1541,16 @@ DriveClient.prototype.saveFile = function(file, revision, success, errFn, noChec
// Logs overwrite
try
{
EditorUi.logError('Warning: Stale Etag Overwrite ' + file.getHash(),
null, file.desc.id + '.' + file.desc.headRevisionId,
((this.user != null) ? ('user_' + this.user.id) : 'nouser') +
((file.sync != null) ? ('-client_' + file.sync.clientId) : '-nosync'));
EditorUi.logEvent({category: 'STALE-ETAG-SAVE-FILE-' + file.getHash(),
action: 'rev_' + file.desc.headRevisionId + '-mod_' + file.desc.modifiedDate +
'-size_' + file.getSize() + '-mime_' + file.desc.mimeType +
((this.ui.editor.autosave) ? '' : '-nosave') +
((file.isAutosave()) ? '' : '-noauto') +
((file.changeListenerEnabled) ? '' : '-nolisten') +
((file.inConflictState) ? '-conflict' : '') +
((file.invalidChecksum) ? '-invalid' : ''),
label: ((this.user != null) ? ('user_' + this.user.id) : 'nouser') +
((file.sync != null) ? ('-client_' + file.sync.clientId) : '-nosync')});
}
catch (e)
{

View file

@ -1715,6 +1715,24 @@
}
};
/**
* Adds the global fontCss configuration.
*/
Editor.prototype.addFontCss = function(svgRoot)
{
var defs = svgRoot.getElementsByTagName('defs');
if (this.fontCss != null && defs != null && defs.length > 0)
{
var svgDoc = svgRoot.ownerDocument;
var style = (svgDoc.createElementNS != null) ?
svgDoc.createElementNS(mxConstants.NS_SVG, 'style') : svgDoc.createElement('style');
style.setAttribute('type', 'text/css');
mxUtils.setTextContent(style, this.fontCss);
defs[0][0].appendChild(style);
}
};
//TODO This function is a replica of EditorUi one, it is planned to replace all calls to EditorUi one to point to this one
/**
* See fixme in convertMath for client-side image generation with math.
@ -4001,20 +4019,21 @@
var x0 = graph.container.scrollLeft - origin.x;
var drawText = imgExport.drawText;
imgExport.drawText = function(state, canvas)
imgExport.drawText = function(state, c)
{
if (state.text != null && state.text.node != null &&
state.text.node.ownerSVGElement == null)
if (c.addForeignObject != null && state.text != null && state.text.checkBounds() &&
state.text.node != null && state.text.node.ownerSVGElement == null)
{
// Copies text into DOM using untransformed bounding box
var tr = state.text.node.style.transform;
state.text.node.style.transform = '';
var rect = state.text.node.getBoundingClientRect();
var clone = state.text.node.cloneNode(true);
state.text.node.style.transform = tr;
c.save();
// Removes unused style
// Copies text into DOM using untransformed bounding box
var clone = state.text.node.cloneNode(true);
// Clears styles that go to wrapper group
clone.style.transformOrigin = '';
clone.style.transform = '';
clone.style.top = '0px';
clone.style.left = '0px';
// Removes all math elements
var ele = clone.getElementsByTagName('math');
@ -4024,56 +4043,53 @@
ele[0].parentNode.removeChild(ele[0]);
}
// Sets position on foreignObject
var s = canvas.state.scale * state.text.scale;
var x = (rect.x + x0) / state.text.scale + canvas.state.dx;
var y = (rect.y + y0) / state.text.scale + canvas.state.dy;
var w = rect.width;
var h = rect.height;
var s = state.text.scale;
var x = state.text.bounds.x / s;
var y = state.text.bounds.y / s;
var w = state.text.bounds.width / s;
var h = state.text.bounds.height / s;
var fo = canvas.root.ownerDocument.createElementNS(mxConstants.NS_SVG, 'foreignObject');
fo.setAttribute('x', x * s);
fo.setAttribute('y', y * s);
fo.setAttribute('width', w);
fo.setAttribute('height', h);
state.text.updateTransform(c, x, y, w, h);
state.text.configureCanvas(c, x, y, w, h);
// Resets position on inner DIV
clone.style.top = '0px';
clone.style.left = '0px';
// Checks if text contains HTML markup
var realHtml = mxUtils.isNode(state.text.value) || state.text.dialect == mxConstants.DIALECT_STRICTHTML;
// Applies transform on foreignObject
var theta = state.text.getTextRotation();
var dx = state.text.margin.x;
var dy = state.text.margin.y;
var tx = (2 * w * dx - w * s * dx) / s;
var ty = (2 * h * dy - h * s * dy) / s;
// Always renders labels as HTML in VML
var fmt = (realHtml || c instanceof mxVmlCanvas2D) ? 'html' : '';
var val = state.text.value;
// FIXME: Center/right aligned text with rotation and export zoom
if (s != 1 && theta != 0)
if (!realHtml && fmt == 'html')
{
// var rad = theta * (Math.PI / 180);
// var pt = mxUtils.getRotatedPoint(new mxPoint(dx, dy), Math.cos(rad), Math.sin(rad));
// tx -= 2 * pt.x * w * s + 2 * pt.y * h * s;
// ty -= 2 * pt.y * h * s + 2 * pt.x * w * s;
// console.log('s', s, theta, dx, w, pt);
val = mxUtils.htmlEntities(val, false);
}
var tr = 'translate(' +
canvas.format(tx) + ',' +
canvas.format(ty) + ')';
if (theta != 0)
if (fmt == 'html' && !mxUtils.isNode(state.text.value))
{
tr += ' rotate(' + theta + ')';
val = mxUtils.replaceTrailingNewlines(val, '<div><br></div>');
}
fo.setAttribute('transform-origin',
canvas.format((x - dx * w) * s) + ' ' +
canvas.format((y - dy * h) * s));
fo.setAttribute('transform', tr +
' scale(' + s + ')');
fo.appendChild(clone);
canvas.root.ownerSVGElement.appendChild(fo);
// Handles trailing newlines to make sure they are visible in rendering output
val = (!mxUtils.isNode(state.text.value) && state.text.replaceLinefeeds && fmt == 'html') ?
val.replace(/\n/g, '<br/>') : val;
var dir = state.text.textDirection;
if (dir == mxConstants.TEXT_DIRECTION_AUTO && !realHtml)
{
dir = state.text.getAutoDirection();
}
if (dir != mxConstants.TEXT_DIRECTION_LTR && dir != mxConstants.TEXT_DIRECTION_RTL)
{
dir = null;
}
c.addForeignObject(x + c.state.dx, y + c.state.dy, w, h, val,
state.text.align, state.text.valign, state.text.wrap, fmt,
state.text.overflow, state.text.clipped, state.text.getTextRotation(),
dir, clone, c.root.ownerSVGElement);
c.restore();
}
else
{

View file

@ -3921,13 +3921,12 @@
/**
* Handling for canvas export.
*/
/**
* See fixme in convertMath for client-side image generation with math.
*/
EditorUi.prototype.isExportToCanvas = function()
{
return mxClient.IS_CHROMEAPP || this.useCanvasForExport;
// FIXME: Safari disabled due to mathjax rendering errors
return mxClient.IS_CHROMEAPP || ((!mxClient.IS_SF ||
!this.editor.graph.mathEnabled) &&
this.useCanvasForExport);
};
/**
@ -4239,7 +4238,8 @@
EditorUi.prototype.openInNewWindow = function(data, mimeType, base64Encoded)
{
// In Google Chrome 60 the code from below produces a blank window
if (mxClient.IS_GC || mxClient.IS_EDGE || document.documentMode == 11 || document.documentMode == 10)
if (mxClient.IS_GC || mxClient.IS_EDGE || mxClient.IS_FF ||
document.documentMode == 11 || document.documentMode == 10)
{
var win = window.open('about:blank');
@ -4591,16 +4591,6 @@
currentPage, null, null, null, false));
}
if (this.editor.fontCss != null)
{
var svgDoc = svgRoot.ownerDocument;
var style = (svgDoc.createElementNS != null) ?
svgDoc.createElementNS(mxConstants.NS_SVG, 'style') : svgDoc.createElement('style');
style.setAttribute('type', 'text/css');
mxUtils.setTextContent(style, this.editor.fontCss);
svgRoot.getElementsByTagName('defs')[0].appendChild(style);
}
var svg = '<?xml version="1.0" encoding="UTF-8"?>\n' +
'<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\n' +
mxUtils.getXml(svgRoot);
@ -4618,6 +4608,9 @@
}
});
// Adds CSS
this.editor.addFontCss(svgRoot);
if (this.editor.graph.mathEnabled)
{
this.editor.addMathCss(svgRoot);
@ -5751,7 +5744,8 @@
*/
EditorUi.prototype.createEmbedSvg = function(fit, shadow, image, lightbox, edit, layers, fn)
{
var svgRoot = this.editor.graph.getSvg();
var svgRoot = this.editor.graph.getSvg(null, null, null, null, null,
null, null, null, null, null, !image);
// Keeps hashtag links on same page
var links = svgRoot.getElementsByTagName('a');
@ -5848,6 +5842,14 @@
svgRoot.setAttribute('style', css);
}
// Adds CSS
this.editor.addFontCss(svgRoot);
if (this.editor.graph.mathEnabled)
{
this.editor.addMathCss(svgRoot);
}
fn(mxUtils.getXml(svgRoot));
}
};
@ -6546,11 +6548,6 @@
addFontCss(this.editor.resolvedFontCss);
}
if (graph.mathEnabled)
{
this.editor.addMathCss(svgRoot);
}
img.src = this.createSvgDataUri(mxUtils.getXml(svgRoot));
});
@ -13203,19 +13200,20 @@
var msgMarkers = msg.msgMarkers;
var callback = this.remoteInvokeCallbacks[msgMarkers.callbackId];
if (callback != null)
if (callback == null)
{
if (msg.error)
{
if (callback.error) callback.error(msg.error.errResp);
}
else if (callback.callback)
{
callback.callback.apply(this, msg.resp);
}
this.remoteInvokeCallbacks[msgMarkers.callbackId] = null; //set it to null only to keep the index
throw new Error('No callback for ' + ((msgMarkers != null) ? msgMarkers.callbackId : 'null'));
}
else if (msg.error)
{
if (callback.error) callback.error(msg.error.errResp);
}
else if (callback.callback)
{
callback.callback.apply(this, msg.resp);
}
this.remoteInvokeCallbacks[msgMarkers.callbackId] = null; //set it to null only to keep the index
};
EditorUi.prototype.remoteInvoke = function(remoteFn, remoteFnArgs, msgMarkers, callback, error)

View file

@ -320,7 +320,8 @@
{
this.libs = (stc != null && (force || stc.length > 0)) ? stc : ((urlParams['libs'] != null &&
urlParams['libs'].length > 0) ? decodeURIComponent(urlParams['libs']) :
((mxSettings != null) ? mxSettings.getLibraries() : this.defaultEntries));
((mxSettings != null && mxSettings.settings != null) ? mxSettings.getLibraries() :
this.defaultEntries));
var tmp = this.libs.split(';');
// Maps library names via the alias table

View file

@ -628,8 +628,28 @@ Actions.prototype.init = function()
graph.zoomTo(1);
ui.resetScrollbars();
}, null, null, Editor.ctrlKey + '+H');
this.addAction('zoomIn', function(evt) { graph.zoomIn(); }, null, null, Editor.ctrlKey + ' + (Numpad) / Alt+Mousewheel');
this.addAction('zoomOut', function(evt) { graph.zoomOut(); }, null, null, Editor.ctrlKey + ' - (Numpad) / Alt+Mousewheel');
this.addAction('zoomIn', function(evt)
{
if (urlParams['zoom'] == 'fast')
{
graph.lazyZoom(true, true);
}
else
{
graph.zoomIn();
}
}, null, null, Editor.ctrlKey + ' + (Numpad) / Alt+Mousewheel');
this.addAction('zoomOut', function(evt)
{
if (urlParams['zoom'] == 'fast')
{
graph.lazyZoom(false, true);
}
else
{
graph.zoomOut();
}
}, null, null, Editor.ctrlKey + ' - (Numpad) / Alt+Mousewheel');
this.addAction('fitWindow', function()
{
var bounds = (graph.isSelectionEmpty()) ? graph.getGraphBounds() : graph.getBoundingBox(graph.getSelectionCells());

View file

@ -2069,8 +2069,10 @@ EditorUi.prototype.initCanvas = function()
graph.cumulativeZoomFactor = 1;
var cursorPosition = null;
var mainGroup = graph.view.getDrawPane();
var bgGroup = graph.view.getBackgroundPane();
graph.lazyZoom = function(zoomIn)
graph.lazyZoom = function(zoomIn, ignoreCursorPosition)
{
if (this.updateZoomTimeout != null)
{
@ -2078,7 +2080,7 @@ EditorUi.prototype.initCanvas = function()
}
// Switches to 1% zoom steps below 15%
// Lower bound depdends on rounding below
// Lower bound depends on rounding below
if (zoomIn)
{
if (this.view.scale * this.cumulativeZoomFactor < 0.15)
@ -2108,10 +2110,48 @@ EditorUi.prototype.initCanvas = function()
}
}
if (urlParams['zoom'] == 'fast')
{
var cx = (ignoreCursorPosition) ? graph.container.scrollWidth / 2 :
cursorPosition.x + graph.container.scrollLeft - graph.container.offsetLeft;
var cy = (ignoreCursorPosition) ? graph.container.scrollHeight / 2 :
cursorPosition.y + graph.container.scrollTop - graph.container.offsetTop;
mainGroup.setAttribute('transform-origin', cx + ' ' + cy);
mainGroup.setAttribute('transform', 'scale(' +
this.cumulativeZoomFactor + ')');
bgGroup.setAttribute('transform-origin', cx + ' ' + cy);
bgGroup.setAttribute('transform', 'scale(' +
this.cumulativeZoomFactor + ')');
var page = graph.view.backgroundPageShape.node;
mxUtils.setPrefixedStyle(page.style, 'transform-origin',
(ignoreCursorPosition) ? '50%' : ((cursorPosition.x + graph.container.offsetLeft - page.offsetLeft) + 'px') + ' ' +
(ignoreCursorPosition) ? '50%' : ((cursorPosition.y - page.offsetTop) + 'px'));
mxUtils.setPrefixedStyle(page.style, 'transform',
'scale(' + this.cumulativeZoomFactor + ')');
graph.view.getOverlayPane().style.opacity = '0';
graph.view.getDecoratorPane().style.opacity = '0';
console.log('here', this.cumulativeZoomFactor, cx, page.offsetLeft, page.offsetWidth);
}
this.cumulativeZoomFactor = Math.max(0.01, Math.min(this.view.scale * this.cumulativeZoomFactor, 160) / this.view.scale);
this.updateZoomTimeout = window.setTimeout(mxUtils.bind(this, function()
{
if (urlParams['zoom'] == 'fast')
{
mainGroup.removeAttribute('transform-origin');
mainGroup.removeAttribute('transform');
bgGroup.removeAttribute('transform-origin');
bgGroup.removeAttribute('transform');
graph.view.getOverlayPane().style.opacity = '';
graph.view.getDecoratorPane().style.opacity = '';
mxUtils.setPrefixedStyle(graph.view.backgroundPageShape.node.style, 'transform-origin', null);
mxUtils.setPrefixedStyle(graph.view.backgroundPageShape.node.style, 'transform', null);
}
var offset = mxUtils.getOffset(graph.container);
var dx = 0;
var dy = 0;
@ -2143,7 +2183,7 @@ EditorUi.prototype.initCanvas = function()
this.cumulativeZoomFactor = 1;
this.updateZoomTimeout = null;
}), this.lazyZoomDelay);
}), (urlParams['zoom'] == 'fast') ? 500 : this.lazyZoomDelay);
};
mxEvent.addMouseWheelListener(mxUtils.bind(this, function(evt, up)

View file

@ -818,19 +818,33 @@ Menus.prototype.createStyleChangeFunction = function(keys, values)
graph.getModel().beginUpdate();
try
{
var cells = graph.getSelectionCells();
for (var i = 0; i < keys.length; i++)
{
graph.setCellStyles(keys[i], values[i]);
graph.setCellStyles(keys[i], values[i], cells);
// Removes CSS alignment to produce consistent output
if (keys[i] == mxConstants.STYLE_ALIGN)
{
graph.updateLabelElements(graph.getSelectionCells(), function(elt)
graph.updateLabelElements(cells, function(elt)
{
elt.removeAttribute('align');
elt.style.textAlign = null;
});
}
// Updates autosize after font changes
if (keys[i] == mxConstants.STYLE_FONTFAMILY)
{
for (var i = 0; i < cells.length; i++)
{
if (graph.model.getChildCount(cells[i]) == 0)
{
graph.autoSizeCell(cells[i], false);
}
}
}
}
if (post != null)
@ -838,8 +852,8 @@ Menus.prototype.createStyleChangeFunction = function(keys, values)
post();
}
this.editorUi.fireEvent(new mxEventObject('styleChanged', 'keys', keys, 'values', values,
'cells', graph.getSelectionCells()));
this.editorUi.fireEvent(new mxEventObject('styleChanged',
'keys', keys, 'values', values, 'cells', cells));
}
finally
{

File diff suppressed because one or more lines are too long