Commit 3959cc596a193b1ceb9d0a359b83018ff1124ca1
1 parent
97e2aed5
perf: add save button && hidden cell tooltip
Showing
3 changed files
with
67 additions
and
21 deletions
@@ -258,7 +258,9 @@ App.DROPBOX_URL = window.DRAWIO_BASE_URL + '/thingskit-drawio/js/dropbox/Dropbox | @@ -258,7 +258,9 @@ App.DROPBOX_URL = window.DRAWIO_BASE_URL + '/thingskit-drawio/js/dropbox/Dropbox | ||
258 | /** | 258 | /** |
259 | * Sets URL to load the Dropbox dropins JS from. | 259 | * Sets URL to load the Dropbox dropins JS from. |
260 | */ | 260 | */ |
261 | -App.DROPINS_URL = 'https://www.dropbox.com/static/api/2/dropins.js'; | 261 | +// App.DROPINS_URL = 'https://www.dropbox.com/static/api/2/dropins.js'; |
262 | +// TODO thingsKit | ||
263 | +App.DROPINS_URL = ''; | ||
262 | 264 | ||
263 | /** | 265 | /** |
264 | * OneDrive Client JS (file/folder picker). This is a slightly modified version to allow using accessTokens | 266 | * OneDrive Client JS (file/folder picker). This is a slightly modified version to allow using accessTokens |
@@ -5859,6 +5861,29 @@ App.prototype.updateButtonContainer = function() | @@ -5859,6 +5861,29 @@ App.prototype.updateButtonContainer = function() | ||
5859 | })); | 5861 | })); |
5860 | this.buttonContainer.appendChild(this.shareButton); | 5862 | this.buttonContainer.appendChild(this.shareButton); |
5861 | 5863 | ||
5864 | + // TODO thingsKit 保存按钮 | ||
5865 | + this.saveButton = document.createElement('div'); | ||
5866 | + this.saveButton.className = 'geBtn gePrimaryBtn'; | ||
5867 | + this.saveButton.style.display = 'inline-block'; | ||
5868 | + this.saveButton.style.backgroundColor = '#F2931E'; | ||
5869 | + this.saveButton.style.borderColor = '#F08705'; | ||
5870 | + this.saveButton.style.backgroundImage = 'none'; | ||
5871 | + this.saveButton.style.marginTop = '-10px'; | ||
5872 | + this.saveButton.style.lineHeight = '28px'; | ||
5873 | + this.saveButton.style.minWidth = '0px'; | ||
5874 | + this.saveButton.style.cssFloat = 'right'; | ||
5875 | + this.saveButton.setAttribute('title', '保存'); | ||
5876 | + mxUtils.write(this.saveButton, '保存'); | ||
5877 | + mxEvent.addListener(this.saveButton, 'click', mxUtils.bind(this, function() | ||
5878 | + { | ||
5879 | + this.currentFile.ui.actions.get( | ||
5880 | + (this.currentFile.mode == null || !this.currentFile.isEditable()) | ||
5881 | + ? 'saveAs' | ||
5882 | + : 'save') | ||
5883 | + .funct(); | ||
5884 | + })); | ||
5885 | + this.buttonContainer.appendChild(this.saveButton); | ||
5886 | + | ||
5862 | 5887 | ||
5863 | // this.shareButton = document.createElement('div'); | 5888 | // this.shareButton = document.createElement('div'); |
5864 | // this.shareButton.className = 'geBtn gePrimaryBtn'; | 5889 | // this.shareButton.className = 'geBtn gePrimaryBtn'; |
@@ -5901,6 +5926,8 @@ App.prototype.updateButtonContainer = function() | @@ -5901,6 +5926,8 @@ App.prototype.updateButtonContainer = function() | ||
5901 | { | 5926 | { |
5902 | this.shareButton.parentNode.removeChild(this.shareButton); | 5927 | this.shareButton.parentNode.removeChild(this.shareButton); |
5903 | this.shareButton = null; | 5928 | this.shareButton = null; |
5929 | + this.saveButton.parentNode.removeChild(this.saveButton); | ||
5930 | + this.saveButton = null; | ||
5904 | } | 5931 | } |
5905 | 5932 | ||
5906 | //Fetch notifications | 5933 | //Fetch notifications |
@@ -350,34 +350,52 @@ | @@ -350,34 +350,52 @@ | ||
350 | } | 350 | } |
351 | 351 | ||
352 | /** | 352 | /** |
353 | + * @description 实例化echarts | ||
354 | + * @param graph | ||
355 | + */ | ||
356 | + Sidebar.prototype.initChartInstance = function (graph) { | ||
357 | + const enumConst = Sidebar.prototype.enumConst | ||
358 | + const allCell = graph.getDefaultParent().children | ||
359 | + const domIdMapping = new Map() | ||
360 | + for (const cell of allCell) { | ||
361 | + const chartInstanceId = graph.getAttributeForCell(cell, enumConst.CHART_CELL_ID) | ||
362 | + if (Sidebar.prototype.isChartCell(cell) && chartInstanceId) { | ||
363 | + const width = graph.getAttributeForCell(cell, enumConst.CHART_CELL_WIDTH) | ||
364 | + const height = graph.getAttributeForCell(cell, enumConst.CHART_CELL_HEIGHT) | ||
365 | + const chartType = graph.getAttributeForCell(cell, enumConst.CHART_TYPE_KEY) | ||
366 | + domIdMapping.set(chartInstanceId, { width, height, chartType }) | ||
367 | + } | ||
368 | + } | ||
369 | + const chartsDomList = document.querySelectorAll(`.${ enumConst.CHART_CONTAINER_CLS }`) | ||
370 | + for (const chartDom of chartsDomList) { | ||
371 | + const id = chartDom.getAttribute('id') | ||
372 | + const { width, height, chartType } = domIdMapping.get(id) | ||
373 | + Sidebar.prototype.generatorEChartInstance(id, width, height, chartType) | ||
374 | + } | ||
375 | + } | ||
376 | + | ||
377 | + /** | ||
353 | * @description 初始化图表 | 378 | * @description 初始化图表 |
354 | */ | 379 | */ |
355 | const openFileHandle = EditorUi.prototype.openFileHandle | 380 | const openFileHandle = EditorUi.prototype.openFileHandle |
356 | EditorUi.prototype.openFileHandle = function () { | 381 | EditorUi.prototype.openFileHandle = function () { |
357 | - const graph = this.editor.graph | ||
358 | - const enumConst = Sidebar.prototype.enumConst | ||
359 | try { | 382 | try { |
360 | openFileHandle.apply(this, arguments) | 383 | openFileHandle.apply(this, arguments) |
361 | } finally { | 384 | } finally { |
362 | - const allCell = graph.getDefaultParent().children | ||
363 | - const domIdMapping = new Map() | ||
364 | - for (const cell of allCell) { | ||
365 | - const chartInstanceId = graph.getAttributeForCell(cell, enumConst.CHART_CELL_ID) | ||
366 | - if (Sidebar.prototype.isChartCell(cell) && chartInstanceId) { | ||
367 | - const width = graph.getAttributeForCell(cell, enumConst.CHART_CELL_WIDTH) | ||
368 | - const height = graph.getAttributeForCell(cell, enumConst.CHART_CELL_HEIGHT) | ||
369 | - const chartType = graph.getAttributeForCell(cell, enumConst.CHART_TYPE_KEY) | ||
370 | - domIdMapping.set(chartInstanceId, { width, height, chartType }) | ||
371 | - } | ||
372 | - } | ||
373 | - const chartsDomList = document.querySelectorAll(`.${ enumConst.CHART_CONTAINER_CLS }`) | ||
374 | - for (const chartDom of chartsDomList) { | ||
375 | - const id = chartDom.getAttribute('id') | ||
376 | - const { width, height, chartType } = domIdMapping.get(id) | ||
377 | - Sidebar.prototype.generatorEChartInstance(id, width, height, chartType) | ||
378 | - } | 385 | + const graph = this.editor.graph |
386 | + Sidebar.prototype.initChartInstance(graph) | ||
379 | } | 387 | } |
380 | } | 388 | } |
381 | 389 | ||
390 | + /** | ||
391 | + * @description 实例化 echarts | ||
392 | + */ | ||
393 | + const refresh = Graph.prototype.refresh | ||
394 | + Graph.prototype.refresh = function () { | ||
395 | + refresh.apply(this, arguments) | ||
396 | + if (!arguments.length) { | ||
397 | + Sidebar.prototype.initChartInstance(this) | ||
398 | + } | ||
399 | + } | ||
382 | })(); | 400 | })(); |
383 | 401 |
@@ -1051,7 +1051,8 @@ Graph = function(container, model, renderHint, stylesheet, themes, standalone) | @@ -1051,7 +1051,8 @@ Graph = function(container, model, renderHint, stylesheet, themes, standalone) | ||
1051 | var tooltipHandlerShow = this.tooltipHandler.show; | 1051 | var tooltipHandlerShow = this.tooltipHandler.show; |
1052 | this.tooltipHandler.show = function() | 1052 | this.tooltipHandler.show = function() |
1053 | { | 1053 | { |
1054 | - tooltipHandlerShow.apply(this, arguments); | 1054 | + // TODO thingsKit hidde cell tooltip |
1055 | + // tooltipHandlerShow.apply(this, arguments); | ||
1055 | 1056 | ||
1056 | if (this.div != null) | 1057 | if (this.div != null) |
1057 | { | 1058 | { |