初始化提交
This commit is contained in:
2
common/blockly-core/plugins/content_highlight.js
Normal file
2
common/blockly-core/plugins/content_highlight.js
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! For license information please see index.js.LICENSE.txt */
|
||||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],e);else{var s="object"==typeof exports?e(require("blockly/core")):e(t.Blockly);for(var i in s)("object"==typeof exports?exports:t)[i]=s[i]}}(this,(t=>(()=>{"use strict";var e={370:e=>{e.exports=t}},s={};function i(t){var o=s[t];if(void 0!==o)return o.exports;var r=s[t]={exports:{}};return e[t](r,r.exports,i),r.exports}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},i.d=(t,e)=>{for(var s in e)i.o(e,s)&&!i.o(t,s)&&Object.defineProperty(t,s,{enumerable:!0,get:e[s]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};i.r(o),i.d(o,{ContentHighlight:()=>h});var r=i(370);const n=[r.Events.VIEWPORT_CHANGE,r.Events.BLOCK_MOVE,r.Events.BLOCK_DELETE,r.Events.COMMENT_MOVE,r.Events.COMMENT_CREATE,r.Events.COMMENT_DELETE];class h{constructor(t){this.workspace=t,this.width=0,this.height=0,this.top=0,this.left=0,this.lastScale=1,this.padding=10,this.theme="#ffffff",this.workspace=t}init(t){this.padding=t||10,this.svgGroup=r.utils.dom.createSvgElement(r.utils.Svg.G,{class:"contentAreaHighlight"},null);const e=String(Math.random()).substring(2),s=r.utils.dom.createSvgElement(new r.utils.Svg("mask"),{id:"contentAreaHighlightMask"+e},this.svgGroup);r.utils.dom.createSvgElement(r.utils.Svg.RECT,{x:0,y:0,width:"100%",height:"100%",fill:"white"},s),this.rect=r.utils.dom.createSvgElement(r.utils.Svg.RECT,{x:0,y:0,rx:r.bubbles.Bubble.BORDER_WIDTH,ry:r.bubbles.Bubble.BORDER_WIDTH,fill:"black"},s),this.background=r.utils.dom.createSvgElement(r.utils.Svg.RECT,{x:0,y:0,width:"100%",height:"100%",mask:`url(#contentAreaHighlightMask${e})`},this.svgGroup);const i=this.workspace.getTheme();this.theme=i.getComponentStyle("workspaceBackgroundColour")||"#ffffff",this.applyColor();const o=this.workspace.getMetricsManager();this.cachedContentMetrics=o.getContentMetrics(!0),this.resize(this.cachedContentMetrics);const n=o.getAbsoluteMetrics();this.position(this.cachedContentMetrics,n),this.svgGroup.style.transition="opacity 0.25s";const h=this.workspace.getParentSvg();h.firstChild?h.insertBefore(this.svgGroup,h.firstChild):h.appendChild(this.svgGroup),this.onChangeWrapper=this.onChange.bind(this),this.workspace.addChangeListener(this.onChangeWrapper)}dispose(){this.svgGroup&&r.utils.dom.removeNode(this.svgGroup),this.onChangeWrapper&&this.workspace.removeChangeListener(this.onChangeWrapper)}onChange(t){if(t.type===r.Events.THEME_CHANGE)this.applyColor();else if(-1!==n.indexOf(t.type)){const e=this.workspace.getMetricsManager();t.type!==r.Events.VIEWPORT_CHANGE&&(this.cachedContentMetrics=e.getContentMetrics(!0),this.resize(this.cachedContentMetrics));const s=e.getAbsoluteMetrics();this.cachedContentMetrics&&this.position(this.cachedContentMetrics,s)}else if(t.type===r.Events.BLOCK_DRAG)this.handleBlockDrag(t);else if(t.type===r.Events.BLOCK_CHANGE){const t=this.workspace.getMetricsManager();this.cachedContentMetrics=t.getContentMetrics(!0),this.resize(this.cachedContentMetrics)}}handleBlockDrag(t){var e;null===(e=this.svgGroup)||void 0===e||e.setAttribute("opacity","1")}applyColor(){var t;const e=r.utils.colour.blend("#000",this.theme,.1),s=r.utils.colour.blend("#fff",this.theme,.1),i="#ffffff"===this.theme||"#fff"===this.theme?e:s;null===(t=this.background)||void 0===t||t.setAttribute("fill",this.theme);const o=this.workspace.getTheme();i!==(o.getComponentStyle("workspaceBackgroundColour")||"#ffffff")&&(o.setComponentStyle("workspaceBackgroundColour",i),this.workspace.setTheme(o))}resize(t){var e,s;const i=t.width?t.width+2*this.padding:0,o=t.height?t.height+2*this.padding:0;i!==this.width&&(this.width=i,null===(e=this.rect)||void 0===e||e.setAttribute("width",`${i}`)),o!==this.height&&(this.height=o,null===(s=this.rect)||void 0===s||s.setAttribute("height",`${o}`))}position(t,e){var s;const i=-this.workspace.scrollY,o=-this.workspace.scrollX,r=this.workspace.scale,n=e.top+t.top*r-i-this.padding*r,h=e.left+t.left*r-o-this.padding*r;n===this.top&&h===this.left&&this.lastScale===r||(this.top=n,this.left=h,this.lastScale=r,null===(s=this.rect)||void 0===s||s.setAttribute("transform",`translate(${h}, ${n}) scale(${r})`))}}return o})()));
|
||||
2
common/blockly-core/plugins/continuous_toolbox.js
Normal file
2
common/blockly-core/plugins/continuous_toolbox.js
Normal file
File diff suppressed because one or more lines are too long
1
common/blockly-core/plugins/disable_top_blocks.js
Normal file
1
common/blockly-core/plugins/disable_top_blocks.js
Normal file
@@ -0,0 +1 @@
|
||||
!function(e,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],o);else{var t="object"==typeof exports?o(require("blockly/core")):o(e.Blockly);for(var r in t)("object"==typeof exports?exports:e)[r]=t[r]}}(this,(e=>(()=>{"use strict";var o={573:o=>{o.exports=e}},t={};function r(e){var n=t[e];if(void 0!==n)return n.exports;var i=t[e]={exports:{}};return o[e](i,i.exports,r),i.exports}r.n=e=>{var o=e&&e.__esModule?()=>e.default:()=>e;return r.d(o,{a:o}),o},r.d=(e,o)=>{for(var t in o)r.o(o,t)&&!r.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:o[t]})},r.o=(e,o)=>Object.prototype.hasOwnProperty.call(e,o),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{r.r(n),r.d(n,{DisableTopBlocks:()=>o});var e=r(573);class o{init(){const o=e.ContextMenuRegistry.registry.getItem("blockDisable");this.oldPreconditionFn=o.preconditionFn,o.preconditionFn=function(e){const o=e.block;return!o.isInFlyout&&o.workspace.options.disable&&o.isEditable()?o.getInheritedDisabled()||t(o)?"disabled":"enabled":"hidden"}}dispose(){e.ContextMenuRegistry.registry.getItem("blockDisable").preconditionFn=this.oldPreconditionFn}}function t(e){const o=e.getParent();return!(!o||!t(o))||!(o||!e.outputConnection&&!e.previousConnection)}})(),n})()));
|
||||
2
common/blockly-core/plugins/field_angle.js
Normal file
2
common/blockly-core/plugins/field_angle.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/field_bitmap.js
Normal file
2
common/blockly-core/plugins/field_bitmap.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/field_colour.js
Normal file
2
common/blockly-core/plugins/field_colour.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/field_colour_hsv_sliders.js
Normal file
2
common/blockly-core/plugins/field_colour_hsv_sliders.js
Normal file
File diff suppressed because one or more lines are too long
1413
common/blockly-core/plugins/field_date.js
Normal file
1413
common/blockly-core/plugins/field_date.js
Normal file
File diff suppressed because it is too large
Load Diff
2
common/blockly-core/plugins/field_dependent_dropdown.js
Normal file
2
common/blockly-core/plugins/field_dependent_dropdown.js
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! For license information please see index.js.LICENSE.txt */
|
||||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],t);else{var n="object"==typeof exports?t(require("blockly/core")):t(e.Blockly);for(var o in n)("object"==typeof exports?exports:e)[o]=n[o]}}(this,(e=>(()=>{"use strict";var t={573:t=>{t.exports=e}},n={};function o(e){var i=n[e];if(void 0!==i)return i.exports;var s=n[e]={exports:{}};return t[e](s,s.exports,o),s.exports}o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{o.r(i),o.d(i,{FieldDependentDropdown:()=>s});var e=o(573);function t(e,n){return e.length===n.length&&e.every(((e,o)=>{const i=n[o];return Array.isArray(e)&&Array.isArray(i)?t(e,i):e===i}))}class n extends e.Events.BlockBase{constructor(e,t,o,i,s,r){super(e),this.type=n.EVENT_TYPE,e&&t&&o&&i&&s&&r&&(this.name=t,this.oldValue=o,this.newValue=i,this.oldOptions=s,this.newOptions=r)}toJson(){const e=super.toJson();if(!(this.name&&this.oldValue&&this.newValue&&this.oldOptions&&this.newOptions))throw new Error("The changed element is undefined. Either pass all needed parameters to the constructor, or call fromJson.");return e.name=this.name,e.oldValue=this.oldValue,e.newValue=this.newValue,e.oldOptions=this.oldOptions,e.newOptions=this.newOptions,e}static fromJson(e,t,n){const o=super.fromJson(e,t,n);return o.name=e.name,o.oldValue=e.oldValue,o.newValue=e.newValue,o.oldOptions=e.oldOptions,o.newOptions=e.newOptions,o}isNull(){const e=this.oldValue===this.newValue,n=this.oldOptions===this.newOptions||Array.isArray(this.oldOptions)&&Array.isArray(this.newOptions)&&t(this.oldOptions,this.newOptions);return e&&n}run(e){if(!(this.blockId&&this.name&&this.oldValue&&this.newValue&&this.oldOptions&&this.newOptions))return void console.warn("Can't run uninitialized event.");const t=this.getEventWorkspace_().getBlockById(this.blockId);if(!t)return void console.warn("Can't change non-existent block: "+this.blockId);const n=t.getField(this.name);if(!n)return void console.warn("Can't change non-existent dropdown field: "+this.name);const o=e?this.newValue:this.oldValue,i=e?this.newOptions:this.oldOptions;n.dependencyData.derivedOptions=i,n.getOptions(!1),n.setValue(o)}}n.EVENT_TYPE="dropdown_options_change",e.registry.register(e.registry.Type.EVENT,n.EVENT_TYPE,n);class s extends e.FieldDropdown{constructor(e,t,n,o,i){const s={};super((()=>{if(s.derivedOptions)return s.derivedOptions;if(s.parentField){const e=s.parentField.getValue();if(e){const n=t[e];if(n)return n}}return n||[["",""]]}),o,i),this.parentName=e,this.optionMapping=t,this.defaultOptions=n,this.dependencyData=s}static fromJson(e){return new s(e.parentName,e.optionMapping,e.defaultOptions,void 0,e)}setSourceBlock(e){var t;super.setSourceBlock(e);const n=e.getField(this.parentName);if(!n)throw new Error("Could not find a parent field with the name "+this.parentName+" for the dependent dropdown.");this.dependencyData.parentField=n;const o=n.getValidator();n.setValidator((e=>{if(o){const t=o(e);if(null===t)return null;void 0!==t&&(e=t)}return this.updateOptionsBasedOnNewValue(e),e})),this.updateOptionsBasedOnNewValue(null!==(t=n.getValue())&&void 0!==t?t:void 0)}updateOptionsBasedOnNewValue(t){if(null==t)return;const o=this.getSourceBlock();if(!o)throw new Error("Could not validate a field that is not attached to a block: "+this.name);const i=this.getValue(),s=this.getOptions(!1);let r=this.optionMapping[t];if(!r){if(!this.defaultOptions)return void console.warn("Could not find child options for the parent value: "+t);r=this.defaultOptions}const l=null!=r.find((e=>e[1]==i))?i:r[0][1];this.dependencyData.derivedOptions=r,this.getOptions(!1),e.Events.disable(),this.setValue(l),e.Events.enable(),e.Events.getRecordUndo()&&(e.Events.getGroup()||(e.Events.setGroup(!0),setTimeout((()=>e.Events.setGroup(!1)))),e.Events.fire(new n(o,this.name,null!=i?i:void 0,null!=l?l:void 0,s,r)))}}Object.defineProperty(e,"FieldDependentDropdown",{value:s,writable:!0,enumerable:!0,configurable:!0}),e.fieldRegistry.register("field_dependent_dropdown",s)})(),i})()));
|
||||
2
common/blockly-core/plugins/field_grid_dropdown.js
Normal file
2
common/blockly-core/plugins/field_grid_dropdown.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/field_multilineinput.js
Normal file
2
common/blockly-core/plugins/field_multilineinput.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/field_slider.js
Normal file
2
common/blockly-core/plugins/field_slider.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/lexical_variables.js
Normal file
2
common/blockly-core/plugins/lexical_variables.js
Normal file
File diff suppressed because one or more lines are too long
157
common/blockly-core/plugins/screenshot.js
Normal file
157
common/blockly-core/plugins/screenshot.js
Normal file
@@ -0,0 +1,157 @@
|
||||
/**
|
||||
* @license
|
||||
* Copyright 2019 Google LLC
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
/**
|
||||
* @fileoverview Download screenshot.
|
||||
*/
|
||||
'use strict';
|
||||
goog.require('Blockly');
|
||||
goog.provide('Blockly.Screenshot');
|
||||
|
||||
/**
|
||||
* Convert an SVG datauri into a PNG datauri.
|
||||
* @param {string} data SVG datauri.
|
||||
* @param {number} width Image width.
|
||||
* @param {number} height Image height.
|
||||
* @param {!Function} callback Callback.
|
||||
*/
|
||||
Blockly.Screenshot.svgToPng_ = function (data, width, height, callback) {
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
const img = new Image();
|
||||
const maxSize = Math.max(width, height);
|
||||
const pixelDensity = Math.max(Math.min(10, 15000 / maxSize), window.devicePixelRatio || 1);
|
||||
canvas.width = width * pixelDensity;
|
||||
canvas.height = height * pixelDensity;
|
||||
img.onload = function () {
|
||||
context.drawImage(
|
||||
img,
|
||||
0,
|
||||
0,
|
||||
width,
|
||||
height,
|
||||
0,
|
||||
0,
|
||||
canvas.width,
|
||||
canvas.height
|
||||
);
|
||||
try {
|
||||
const dataUri = canvas.toDataURL('image/png');
|
||||
callback(dataUri);
|
||||
} catch (err) {
|
||||
console.warn('Error converting the workspace svg to a png');
|
||||
callback('');
|
||||
}
|
||||
};
|
||||
img.src = data;
|
||||
}
|
||||
|
||||
Blockly.Screenshot.getBase64Image_ = function(image) {
|
||||
return new Promise(resolve => {
|
||||
const img = new Image();
|
||||
img.crossOrigin = '';
|
||||
const href = image.getAttribute('xlink:href');
|
||||
if (!href) {
|
||||
resolve();
|
||||
}
|
||||
img.src = href;
|
||||
img.onload = function () {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx?.drawImage(img, 0, 0, img.width, img.height);
|
||||
const ext = img.src.substring(img.src.lastIndexOf('.') + 1).toLowerCase();
|
||||
const dataURL = canvas.toDataURL('image/' + ext);
|
||||
image.setAttribute('xlink:href', dataURL);
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an SVG of the blocks on the workspace.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The workspace.
|
||||
* @param {!Function} callback Callback.
|
||||
* @param {string=} customCss Custom CSS to append to the SVG.
|
||||
*/
|
||||
Blockly.Screenshot.workspaceToSvg_ = function (workspace, callback, customCss) {
|
||||
// Go through all text areas and set their value.
|
||||
const textAreas = document.getElementsByTagName('textarea');
|
||||
for (let i = 0; i < textAreas.length; i++) {
|
||||
textAreas[i].innerHTML = textAreas[i].value;
|
||||
}
|
||||
|
||||
const bBox = workspace.getBlocksBoundingBox();
|
||||
const x = bBox.x || bBox.left;
|
||||
const y = bBox.y || bBox.top;
|
||||
const width = bBox.width || bBox.right - x;
|
||||
const height = bBox.height || bBox.bottom - y;
|
||||
|
||||
const blockCanvas = workspace.getCanvas();
|
||||
const clone = blockCanvas.cloneNode(true);
|
||||
clone.removeAttribute('transform');
|
||||
const $images = $(clone).find('image');
|
||||
let resolveList = [];
|
||||
for (let i = 0; i < $images.length; i++) {
|
||||
resolveList.push(this.getBase64Image_($images[i]));
|
||||
}
|
||||
|
||||
Promise.all(resolveList)
|
||||
.then(() => {
|
||||
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
svg.setAttribute('xmlns', 'http://www.w3.org/2000/svg');
|
||||
svg.appendChild(clone);
|
||||
svg.setAttribute('viewBox', x + ' ' + y + ' ' + width + ' ' + height);
|
||||
|
||||
svg.setAttribute(
|
||||
'class',
|
||||
'blocklySvg ' +
|
||||
(workspace.options.renderer || 'geras') +
|
||||
'-renderer ' +
|
||||
(workspace.getTheme ? workspace.getTheme().name + '-theme' : '')
|
||||
);
|
||||
svg.setAttribute('width', width);
|
||||
svg.setAttribute('height', height);
|
||||
svg.setAttribute('style', 'background-color: transparent');
|
||||
|
||||
const css = [].slice
|
||||
.call(document.head.querySelectorAll('style'))
|
||||
.filter(
|
||||
(el) =>
|
||||
/\.blocklySvg/.test(el.innerText) || el.id.indexOf('blockly-') === 0
|
||||
)
|
||||
.map((el) => el.innerText)
|
||||
.join('\n');
|
||||
const style = document.createElement('style');
|
||||
style.innerHTML = css + '\n' + customCss;
|
||||
svg.insertBefore(style, svg.firstChild);
|
||||
|
||||
let svgAsXML = new XMLSerializer().serializeToString(svg);
|
||||
svgAsXML = svgAsXML.replace(/ /g, ' ');
|
||||
const data = 'data:image/svg+xml,' + encodeURIComponent(svgAsXML);
|
||||
|
||||
Blockly.Screenshot.svgToPng_(data, width, height, callback);
|
||||
});
|
||||
}
|
||||
|
||||
/* eslint-disable no-unused-vars */
|
||||
/**
|
||||
* Download a screenshot of the blocks on a Blockly workspace.
|
||||
* @param {!Blockly.WorkspaceSvg} workspace The Blockly workspace.
|
||||
*/
|
||||
Blockly.Screenshot.downloadScreenshot = function (workspace) {
|
||||
Blockly.Screenshot.workspaceToSvg_(workspace, function (datauri) {
|
||||
const a = document.createElement('a');
|
||||
a.download = 'screenshot.png';
|
||||
a.target = '_self';
|
||||
a.href = datauri;
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
a.parentNode.removeChild(a);
|
||||
});
|
||||
}
|
||||
/* eslint-enable */
|
||||
2
common/blockly-core/plugins/workspace_backpack.js
Normal file
2
common/blockly-core/plugins/workspace_backpack.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/workspace_minimap.js
Normal file
2
common/blockly-core/plugins/workspace_minimap.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/workspace_multiselect.js
Normal file
2
common/blockly-core/plugins/workspace_multiselect.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/workspace_search.js
Normal file
2
common/blockly-core/plugins/workspace_search.js
Normal file
File diff suppressed because one or more lines are too long
2
common/blockly-core/plugins/zoom_to_fit.js
Normal file
2
common/blockly-core/plugins/zoom_to_fit.js
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! For license information please see index.js.LICENSE.txt */
|
||||
!function(t,o){if("object"==typeof exports&&"object"==typeof module)module.exports=o(require("blockly/core"));else if("function"==typeof define&&define.amd)define(["blockly/core"],o);else{var e="object"==typeof exports?o(require("blockly/core")):o(t.Blockly);for(var i in e)("object"==typeof exports?exports:t)[i]=e[i]}}(this,(t=>(()=>{"use strict";var o={573:o=>{o.exports=t}},e={};function i(t){var r=e[t];if(void 0!==r)return r.exports;var s=e[t]={exports:{}};return o[t](s,s.exports,i),s.exports}i.n=t=>{var o=t&&t.__esModule?()=>t.default:()=>t;return i.d(o,{a:o}),o},i.d=(t,o)=>{for(var e in o)i.o(o,e)&&!i.o(t,e)&&Object.defineProperty(t,e,{enumerable:!0,get:o[e]})},i.o=(t,o)=>Object.prototype.hasOwnProperty.call(t,o),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{ZoomToFitControl:()=>s});var t=i(573);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function e(t,e){for(var i=0;i<e.length;i++){var r=e[i];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,(void 0,s=function(t,e){if("object"!==o(t)||null===t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var r=i.call(t,"string");if("object"!==o(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(r.key),"symbol"===o(s)?s:String(s)),r)}var s}var s=function(){function o(t){!function(t,o){if(!(t instanceof o))throw new TypeError("Cannot call a class as a function")}(this,o),this.workspace_=t,this.id="zoomToFit",this.svgGroup_=null,this.left_=0,this.top_=0,this.WIDTH_=32,this.HEIGHT_=32,this.MARGIN_VERTICAL_=20,this.MARGIN_HORIZONTAL_=20,this.initialized_=!1}var i,r;return i=o,(r=[{key:"init",value:function(){this.workspace_.getComponentManager().addComponent({component:this,weight:2,capabilities:[t.ComponentManager.Capability.POSITIONABLE]}),this.createDom_(),this.initialized_=!0,this.workspace_.resize()}},{key:"dispose",value:function(){this.svgGroup_&&t.utils.dom.removeNode(this.svgGroup_),this.onZoomToFitWrapper_&&t.unbindEvent_(this.onZoomToFitWrapper_)}},{key:"createDom_",value:function(){this.svgGroup_=t.utils.dom.createSvgElement(t.utils.Svg.IMAGE,{height:this.HEIGHT_+"px",width:this.WIDTH_+"px",class:"zoomToFit"}),this.svgGroup_.setAttributeNS(t.utils.dom.XLINK_NS,"xlink:href",n),t.utils.dom.insertAfter(this.svgGroup_,this.workspace_.getBubbleCanvas()),this.onZoomToFitWrapper_=t.browserEvents.conditionalBind(this.svgGroup_,"mousedown",null,this.onClick_.bind(this))}},{key:"onClick_",value:function(){this.workspace_.zoomToFit();var o=new(t.Events.get(t.Events.CLICK))(null,this.workspace_.id,"zoom_reset_control");t.Events.fire(o)}},{key:"getBoundingRectangle",value:function(){return new t.utils.Rect(this.top_,this.top_+this.HEIGHT_,this.left_,this.left_+this.WIDTH_)}},{key:"position",value:function(o,e){if(this.initialized_){var i=this.workspace_.scrollbar&&this.workspace_.scrollbar.canScrollHorizontally(),r=this.workspace_.scrollbar&&this.workspace_.scrollbar.canScrollVertically();o.toolboxMetrics.position===t.TOOLBOX_AT_LEFT||this.workspace_.horizontalLayout&&!this.workspace_.RTL?(this.left_=o.absoluteMetrics.left+o.viewMetrics.width-this.WIDTH_-this.MARGIN_HORIZONTAL_,i&&!this.workspace_.RTL&&(this.left_-=t.Scrollbar.scrollbarThickness)):(this.left_=this.MARGIN_HORIZONTAL_,i&&this.workspace_.RTL&&(this.left_+=t.Scrollbar.scrollbarThickness));var s=o.toolboxMetrics.position!==t.TOOLBOX_AT_BOTTOM;s?(this.top_=o.absoluteMetrics.top+o.viewMetrics.height-this.HEIGHT_-this.MARGIN_VERTICAL_,r&&(this.top_-=t.Scrollbar.scrollbarThickness)):this.top_=o.absoluteMetrics.top+this.MARGIN_VERTICAL_;for(var n,l=this.getBoundingRectangle(),a=0;n=e[a];a++)l.intersects(n)&&(this.top_=s?n.top-this.HEIGHT_-this.MARGIN_VERTICAL_:n.bottom+this.MARGIN_VERTICAL_,l=this.getBoundingRectangle(),a=-1);this.svgGroup_.setAttribute("transform","translate("+this.left_+","+this.top_+")")}}}])&&e(i.prototype,r),Object.defineProperty(i,"prototype",{writable:!1}),o}(),n="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjRweCIgdmlld0JveD0iMCAwIDI0IDI0IiB3aWR0aD0iMjRweCIgZmlsbD0iIzU0NkU3QSI+PHBhdGggZD0iTTAgMGgyNHYyNEgwVjB6IiBmaWxsPSJub25lIi8+PHBhdGggZD0iTTUgNi40Mkw4LjA5IDkuNSA5LjUgOC4wOSA2LjQxIDVIOVYzSDN2Nmgyem0xMC0zLjQxdjJoMi41N0wxNC41IDguMDlsMS40MSAxLjQxTDE5IDYuNDFWOWgyVjMuMDF6bTQgMTQuNTdsLTMuMDktMy4wOC0xLjQxIDEuNDFMMTcuNTkgMTlIMTV2Mmg2di02aC0yek04LjA5IDE0LjVMNSAxNy41OVYxNUgzdjZoNnYtMkg2LjQybDMuMDgtMy4wOXoiLz48L3N2Zz4=";t.Css.register(["\n .zoomToFit {\n opacity: .4;\n }\n .zoomToFit:hover {\n opacity: .6;\n }\n .zoomToFit:active {\n opacity: .8;\n }\n"])})(),r})()));
|
||||
Reference in New Issue
Block a user