- Build: Update

This commit is contained in:
Brett Zamir
2020-07-27 12:02:12 +08:00
parent be5d353bc4
commit fe089f742e
13 changed files with 136 additions and 78 deletions

View File

@@ -207,7 +207,7 @@ var svgEditorExtension_mathjax = (function () {
mathjax: {
embed_svg: 'Save as mathematics',
embed_mathml: 'Save as figure',
svg_save_warning: 'The math will be transformed into a figure is manipulatable like everything else. You will not be able to manipulate the TeX-code anymore. ',
svg_save_warning: 'The math will be transformed into a figure is ' + 'manipulatable like everything else. You will not be able to ' + 'manipulate the TeX-code anymore.',
mathml_save_warning: 'Advised. The math will be saved as a figure.',
title: 'Mathematics code editor'
}
@@ -237,7 +237,7 @@ var svgEditorExtension_mathjax = (function () {
break;
}
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:Displaying_a_formula" target="_blank">TeX</a> code.</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('<div id="mathjax">' + '<!-- Here is where MathJax creates the math -->' + '<div id="mathjax_creator" class="tex2jax_process" style="display:none">' + '$${}$$' + '</div>' + '<div id="mathjax_overlay"></div>' + '<div id="mathjax_container">' + '<div id="tool_mathjax_back" class="toolbar_button">' + '<button id="tool_mathjax_save">OK</button>' + '<button id="tool_mathjax_cancel">Cancel</button>' + '</div>' + '<fieldset>' + '<legend id="mathjax_legend">Mathematics Editor</legend>' + '<label>' + '<span id="mathjax_explication">Please type your mathematics in ' + '<a href="https://en.wikipedia.org/wiki/Help:' + 'Displaying_a_formula" target="_blank">TeX</a> code.' + '</span></label>' + '<textarea id="mathjax_code_textarea" spellcheck="false"></textarea>' + '</fieldset>' + '</div>' + '</div>').insertAfter('#svg_prefs').hide(); // Make the MathEditor draggable.
$('#mathjax_container').draggable({
cancel: 'button,fieldset',

View File

@@ -28,7 +28,7 @@ var svgEditorExtension_overview_window = (function () {
} // Define and insert the base html element.
var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" y="0" viewBox="0 0 4800 3600" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; min-height:50px; position:absolute; top:30px; left:30px; z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
var propsWindowHtml = '<div id="overview_window_content_pane" style="width:100%; ' + 'word-wrap:break-word; display:inline-block; margin-top:20px;">' + '<div id="overview_window_content" style="position:relative; ' + 'left:12px; top:0px;">' + '<div style="background-color:#A0A0A0; display:inline-block; ' + 'overflow:visible;">' + '<svg id="overviewMiniView" width="150" height="100" x="0" ' + 'y="0" viewBox="0 0 4800 3600" ' + 'xmlns="http://www.w3.org/2000/svg" ' + 'xmlns:xlink="http://www.w3.org/1999/xlink">' + '<use x="0" y="0" xlink:href="#svgroot"> </use>' + '</svg>' + '<div id="overview_window_view_box" style="min-width:50px; ' + 'min-height:50px; position:absolute; top:30px; left:30px; ' + 'z-index:5; background-color:rgba(255,0,102,0.3);">' + '</div>' + '</div>' + '</div>' + '</div>';
$('#sidepanels').append(propsWindowHtml); // Define dynamic animation of the view box.
var updateViewBox = function updateViewBox() {

View File

@@ -1799,10 +1799,21 @@ var svgEditorExtension_server_moinsave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
}
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width - desiredWidth, 0);
}
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height - desiredHeight);
}
} // scale
@@ -3022,7 +3033,11 @@ var svgEditorExtension_server_moinsave = (function () {
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') {
ctx.rotate(-angle);
}
ctx.translate(-point.x, -point.y);
}
}]);
@@ -4156,7 +4171,8 @@ var svgEditorExtension_server_moinsave = (function () {
var tempSvg = element;
if (element.type === 'symbol') {
// render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement)
// render me using a temporary svg element in symbol cases
// (https://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value);
@@ -4167,8 +4183,13 @@ var svgEditorExtension_server_moinsave = (function () {
if (tempSvg.type === 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
if (this.attribute('width').hasValue()) {
tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
}
if (this.attribute('height').hasValue()) {
tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
}
}
var oldParent = tempSvg.parent;
@@ -4783,9 +4804,9 @@ var svgEditorExtension_server_moinsave = (function () {
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility?
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);

View File

@@ -1799,10 +1799,21 @@ var svgEditorExtension_server_opensave = (function () {
ctx.translate(-scaleMin * refX.toPixels('x'), -scaleMin * refY.toPixels('y'));
} else {
// align
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) ctx.translate(width - desiredWidth, 0);
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) ctx.translate(0, height - desiredHeight);
if (align.startsWith('xMid') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width / 2.0 - desiredWidth / 2.0, 0);
}
if (align.endsWith('YMid') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height / 2.0 - desiredHeight / 2.0);
}
if (align.startsWith('xMax') && (meetOrSlice === 'meet' && scaleMin === scaleY || meetOrSlice === 'slice' && scaleMax === scaleY)) {
ctx.translate(width - desiredWidth, 0);
}
if (align.endsWith('YMax') && (meetOrSlice === 'meet' && scaleMin === scaleX || meetOrSlice === 'slice' && scaleMax === scaleX)) {
ctx.translate(0, height - desiredHeight);
}
} // scale
@@ -3022,7 +3033,11 @@ var svgEditorExtension_server_opensave = (function () {
tempSvg.render(ctx);
ctx.restore();
if (this.attribute('markerUnits').valueOrDefault('strokeWidth') === 'strokeWidth') ctx.scale(1 / ctx.lineWidth, 1 / ctx.lineWidth);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') ctx.rotate(-angle);
if (this.attribute('orient').valueOrDefault('auto') === 'auto') {
ctx.rotate(-angle);
}
ctx.translate(-point.x, -point.y);
}
}]);
@@ -4156,7 +4171,8 @@ var svgEditorExtension_server_opensave = (function () {
var tempSvg = element;
if (element.type === 'symbol') {
// render me using a temporary svg element in symbol cases (https://www.w3.org/TR/SVG/struct.html#UseElement)
// render me using a temporary svg element in symbol cases
// (https://www.w3.org/TR/SVG/struct.html#UseElement)
tempSvg = new svg.Element.svg();
tempSvg.type = 'svg';
tempSvg.attributes.viewBox = new svg.Property('viewBox', element.attribute('viewBox').value);
@@ -4167,8 +4183,13 @@ var svgEditorExtension_server_opensave = (function () {
if (tempSvg.type === 'svg') {
// if symbol or svg, inherit width/height from me
if (this.attribute('width').hasValue()) tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
if (this.attribute('height').hasValue()) tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
if (this.attribute('width').hasValue()) {
tempSvg.attributes.width = new svg.Property('width', this.attribute('width').value);
}
if (this.attribute('height').hasValue()) {
tempSvg.attributes.height = new svg.Property('height', this.attribute('height').value);
}
}
var oldParent = tempSvg.parent;
@@ -4783,9 +4804,9 @@ var svgEditorExtension_server_opensave = (function () {
svg.Mouse.runEvents(); // run and clear our events
}
}, 1000 / svg.FRAMERATE); // Todo: Replace with an image loading Promise utility?
// eslint-disable-next-line promise/avoid-new
return new Promise(function (resolve, reject) {
// eslint-disable-line promise/avoid-new
if (svg.ImagesLoaded()) {
waitingForImages = false;
draw(resolve);