|
@@ -1570,7 +1570,7 @@ var BackgroundImageDialog = function(editorUi, applyFn, img)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- if (isPageLink || editorUi.pages == null || editorUi.pages.length == 1)
|
|
|
+ if (!isPageLink && (editorUi.pages == null || editorUi.pages.length == 1))
|
|
|
{
|
|
|
urlRadio.style.display = 'none';
|
|
|
pageRadio.style.display = 'none';
|
|
@@ -7456,7 +7456,6 @@ var FindWindow = function(ui, x, y, w, h, withReplace)
|
|
|
var FreehandWindow = function(editorUi, x, y, w, h)
|
|
|
{
|
|
|
var graph = editorUi.editor.graph;
|
|
|
- var propertyName = 'tags';
|
|
|
|
|
|
var div = document.createElement('div');
|
|
|
div.style.textAlign = 'center';
|
|
@@ -7551,7 +7550,7 @@ var FreehandWindow = function(editorUi, x, y, w, h)
|
|
|
var TagsWindow = function(editorUi, x, y, w, h)
|
|
|
{
|
|
|
var graph = editorUi.editor.graph;
|
|
|
- var propertyName = 'tags';
|
|
|
+ var allTags = [];
|
|
|
|
|
|
var div = document.createElement('div');
|
|
|
div.style.userSelect = 'none';
|
|
@@ -7559,151 +7558,432 @@ var TagsWindow = function(editorUi, x, y, w, h)
|
|
|
div.style.padding = '10px';
|
|
|
div.style.height = '100%';
|
|
|
|
|
|
- var searchInput = document.createElement('input');
|
|
|
- searchInput.setAttribute('placeholder', mxResources.get('allTags'));
|
|
|
- searchInput.setAttribute('type', 'text');
|
|
|
- searchInput.style.marginTop = '4px';
|
|
|
- searchInput.style.width = '260px';
|
|
|
- searchInput.style.fontSize = '12px';
|
|
|
- searchInput.style.borderRadius = '4px';
|
|
|
- searchInput.style.padding = '6px';
|
|
|
- div.appendChild(searchInput);
|
|
|
-
|
|
|
- if (!editorUi.isOffline() || mxClient.IS_CHROMEAPP)
|
|
|
- {
|
|
|
- searchInput.style.width = '240px';
|
|
|
- var elt = editorUi.menus.createHelpLink('https://www.diagrams.net/doc/faq/tags');
|
|
|
- elt.firstChild.style.marginBottom = '6px';
|
|
|
- elt.style.marginLeft = '6px';
|
|
|
- div.appendChild(elt);
|
|
|
- }
|
|
|
-
|
|
|
- mxEvent.addListener(searchInput, 'dblclick', function()
|
|
|
+ var tagCloud = document.createElement('div');
|
|
|
+ tagCloud.style.border = '1px solid #808080';
|
|
|
+ tagCloud.style.boxSizing = 'border-box';
|
|
|
+ tagCloud.style.borderRadius = '4px';
|
|
|
+ tagCloud.style.userSelect = 'none';
|
|
|
+ tagCloud.style.overflowY = 'scroll';
|
|
|
+ tagCloud.style.position = 'absolute';
|
|
|
+ tagCloud.style.left = '10px';
|
|
|
+ tagCloud.style.right = '10px';
|
|
|
+ tagCloud.style.top = '10px';
|
|
|
+ tagCloud.style.bottom = '68px';
|
|
|
+
|
|
|
+ div.appendChild(tagCloud);
|
|
|
+
|
|
|
+ var options = document.createElement('div');
|
|
|
+ options.style.position = 'absolute';
|
|
|
+ options.style.left = '10px';
|
|
|
+ options.style.right = '10px';
|
|
|
+ options.style.height = '10px';
|
|
|
+ options.style.bottom = '54px';
|
|
|
+
|
|
|
+ var removeCb = document.createElement('input');
|
|
|
+ removeCb.setAttribute('type', 'checkbox');
|
|
|
+ removeCb.setAttribute('id', 'geRemoveUnusedTags');
|
|
|
+ removeCb.style.marginRight = '8px';
|
|
|
+ options.appendChild(removeCb);
|
|
|
+
|
|
|
+ var span = document.createElement('label');
|
|
|
+ span.setAttribute('for', 'geRemoveUnusedTags');
|
|
|
+ mxUtils.write(span, mxResources.get('removeUnusedTags'));
|
|
|
+ span.style.textOverflow = 'ellipsis';
|
|
|
+ span.style.position = 'relative';
|
|
|
+ span.style.top = '-1px';
|
|
|
+ options.appendChild(span);
|
|
|
+ div.appendChild(options);
|
|
|
+
|
|
|
+ mxEvent.addListener(removeCb, 'change', function(evt)
|
|
|
+ {
|
|
|
+ refreshUi();
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
+
|
|
|
+ var addBtn = mxUtils.button(mxResources.get('add') + '...', function()
|
|
|
{
|
|
|
- var dlg = new FilenameDialog(editorUi, propertyName, mxResources.get('ok'), mxUtils.bind(this, function(name)
|
|
|
+ if (graph.isEnabled())
|
|
|
{
|
|
|
- if (name != null && name.length > 0)
|
|
|
+ var dlg = new FilenameDialog(editorUi, '', mxResources.get('add'), function(newValue)
|
|
|
{
|
|
|
- propertyName = name;
|
|
|
- }
|
|
|
- }), mxResources.get('enterPropertyName'));
|
|
|
- editorUi.showDialog(dlg.container, 300, 80, true, true);
|
|
|
- dlg.init();
|
|
|
+ editorUi.hideDialog();
|
|
|
+
|
|
|
+ if (newValue != null && newValue.length > 0)
|
|
|
+ {
|
|
|
+ var temp = newValue.split(' ');
|
|
|
+ var tags = [];
|
|
|
+
|
|
|
+ for (var i = 0; i < temp.length; i++)
|
|
|
+ {
|
|
|
+ var tag = mxUtils.trim(temp[i]);
|
|
|
+
|
|
|
+ if (tag != '')
|
|
|
+ {
|
|
|
+ tags.push(tag);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (tags.length > 0)
|
|
|
+ {
|
|
|
+ if (graph.isSelectionEmpty())
|
|
|
+ {
|
|
|
+ allTags = allTags.concat(tags);
|
|
|
+ refreshUi();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ graph.addTagsForCells(graph.getSelectionCells(), tags);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, mxResources.get('enterValue') + ' (' + mxResources.get('tags') + ')');
|
|
|
+
|
|
|
+ editorUi.showDialog(dlg.container, 300, 80, true, true);
|
|
|
+ dlg.init();
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
- searchInput.setAttribute('title', mxResources.get('doubleClickChangeProperty'));
|
|
|
+ addBtn.setAttribute('title', mxResources.get('add'));
|
|
|
+ addBtn.className = 'geBtn';
|
|
|
+ addBtn.marginTop = '4px';
|
|
|
|
|
|
- function searchCells(cells)
|
|
|
+ graph.addListener(mxEvent.ROOT, function()
|
|
|
{
|
|
|
- return graph.getCellsForTags(searchInput.value.split(' '), cells, propertyName, true);
|
|
|
- };
|
|
|
+ allTags = [];
|
|
|
+ });
|
|
|
|
|
|
- function setCellsVisible(cells, visible)
|
|
|
+ function refreshButtons()
|
|
|
{
|
|
|
- graph.setCellsVisible(cells, visible);
|
|
|
+ if (graph.isSelectionEmpty() && removeCb.checked)
|
|
|
+ {
|
|
|
+ addBtn.setAttribute('disabled', 'disabled');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ addBtn.removeAttribute('disabled');
|
|
|
+ }
|
|
|
};
|
|
|
-
|
|
|
- mxUtils.br(div);
|
|
|
|
|
|
- var hideBtn = mxUtils.button(mxResources.get('hide'), function()
|
|
|
+ function refreshTags(tags, selected)
|
|
|
{
|
|
|
- setCellsVisible(searchCells(), false);
|
|
|
- });
|
|
|
-
|
|
|
- hideBtn.setAttribute('title', mxResources.get('hide'));
|
|
|
- hideBtn.style.marginTop = '8px';
|
|
|
- hideBtn.style.marginRight = '4px';
|
|
|
- hideBtn.className = 'geBtn';
|
|
|
-
|
|
|
- div.appendChild(hideBtn);
|
|
|
+ tagCloud.innerHTML = '';
|
|
|
|
|
|
- var showBtn = mxUtils.button(mxResources.get('show'), function()
|
|
|
- {
|
|
|
- var cells = searchCells();
|
|
|
- setCellsVisible(cells, true);
|
|
|
-
|
|
|
- if (graph.isEnabled())
|
|
|
+ if (tags.length > 0)
|
|
|
{
|
|
|
- // Ignores layers for selection
|
|
|
- var temp = [];
|
|
|
-
|
|
|
- for (var i = 0; i < cells.length; i++)
|
|
|
+ var table = document.createElement('table');
|
|
|
+ table.setAttribute('cellpadding', '2');
|
|
|
+ table.style.boxSizing = 'border-box';
|
|
|
+ table.style.width = '100%';
|
|
|
+
|
|
|
+ var tbody = document.createElement('tbody');
|
|
|
+
|
|
|
+ var row = document.createElement('tr');
|
|
|
+ var td = document.createElement('td');
|
|
|
+ var a = document.createElement('a');
|
|
|
+ a.style.fontSize = '10px';
|
|
|
+ a.style.cursor = 'pointer';
|
|
|
+ a.setAttribute('title', mxResources.get(
|
|
|
+ (graph.hiddenTags.length == 0) ?
|
|
|
+ 'selectNone' : 'selectAll'));
|
|
|
+ mxUtils.write(a, mxResources.get('show'));
|
|
|
+ td.appendChild(a);
|
|
|
+ row.appendChild(td);
|
|
|
+
|
|
|
+ mxEvent.addListener(a, 'click', function(evt)
|
|
|
+ {
|
|
|
+ if (graph.hiddenTags.length == 0)
|
|
|
+ {
|
|
|
+ graph.hiddenTags = allTags.slice();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ graph.hiddenTags = [];
|
|
|
+ }
|
|
|
+
|
|
|
+ graph.clearSelection();
|
|
|
+ graph.refresh();
|
|
|
+
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
+
|
|
|
+ if (graph.isEnabled())
|
|
|
{
|
|
|
- if (!graph.isCellLocked(cells[i]) &&
|
|
|
- (graph.model.isVertex(cells[i]) ||
|
|
|
- graph.model.isEdge(cells[i])))
|
|
|
+ td = document.createElement('td');
|
|
|
+ a = document.createElement('a');
|
|
|
+ a.style.fontSize = '10px';
|
|
|
+ mxUtils.write(a, mxResources.get('tags'));
|
|
|
+ td.appendChild(a);
|
|
|
+
|
|
|
+ if (graph.isEnabled() && !graph.isSelectionEmpty())
|
|
|
{
|
|
|
- temp.push(cells[i]);
|
|
|
+ a.setAttribute('title', mxResources.get('selectAll'));
|
|
|
+ a.style.cursor = 'pointer';
|
|
|
+
|
|
|
+ mxEvent.addListener(a, 'click', function(evt)
|
|
|
+ {
|
|
|
+ graph.addTagsForCells(graph.getSelectionCells(), allTags);
|
|
|
+ graph.refresh();
|
|
|
+
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
}
|
|
|
+
|
|
|
+ row.appendChild(td);
|
|
|
}
|
|
|
+
|
|
|
+ td = document.createElement('td');
|
|
|
+
|
|
|
+ a = document.createElement('a');
|
|
|
+ a.style.fontSize = '10px';
|
|
|
+ a.style.cursor = 'pointer';
|
|
|
+ a.setAttribute('title', mxResources.get('selectAll') +
|
|
|
+ ' (' + mxResources.get('allTags') + ')');
|
|
|
+ mxUtils.write(a, mxResources.get('select'));
|
|
|
+
|
|
|
+ mxEvent.addListener(a, 'click', function(evt)
|
|
|
+ {
|
|
|
+ var cells = graph.getCellsForTags([]);
|
|
|
+
|
|
|
+ if (graph.isEnabled())
|
|
|
+ {
|
|
|
+ graph.setSelectionCells(cells, null, null, true);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ graph.highlightCells(cells);
|
|
|
+ }
|
|
|
+
|
|
|
+ refreshUi();
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
+
|
|
|
+ td.appendChild(a);
|
|
|
+
|
|
|
+ td.style.width = '100%';
|
|
|
+ row.appendChild(td);
|
|
|
+ tbody.appendChild(row);
|
|
|
+
|
|
|
+ var td2 = document.createElement('td');
|
|
|
+
|
|
|
+ if (tags != null && tags.length > 0)
|
|
|
+ {
|
|
|
+ for (var i = 0; i < tags.length; i++)
|
|
|
+ {
|
|
|
+ (function(tag)
|
|
|
+ {
|
|
|
+ var row = document.createElement('tr');
|
|
|
+ var td = document.createElement('td');
|
|
|
+ td.style.textAlign = 'center';
|
|
|
+
|
|
|
+ var cb = document.createElement('input');
|
|
|
+ cb.setAttribute('type', 'checkbox');
|
|
|
+ cb.style.marginRight = '4px';
|
|
|
+
|
|
|
+ cb.defaultChecked = mxUtils.indexOf(graph.hiddenTags, tag) < 0;
|
|
|
+ cb.checked = cb.defaultChecked;
|
|
|
+ cb.setAttribute('title', mxResources.get(
|
|
|
+ cb.defaultChecked ? 'hide' : 'show'));
|
|
|
+
|
|
|
+ mxEvent.addListener(cb, 'change', function(evt)
|
|
|
+ {
|
|
|
+ var idx = mxUtils.indexOf(graph.hiddenTags, tag)
|
|
|
+
|
|
|
+ if (idx < 0 && !cb.checked)
|
|
|
+ {
|
|
|
+ graph.hiddenTags.push(tag);
|
|
|
+ }
|
|
|
+ else if (idx >= 0 && cb.checked)
|
|
|
+ {
|
|
|
+ graph.hiddenTags.splice(idx, 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ graph.clearSelection();
|
|
|
+ graph.refresh();
|
|
|
+
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
+
|
|
|
+ td.appendChild(cb);
|
|
|
+ row.appendChild(td);
|
|
|
|
|
|
- graph.setSelectionCells(temp);
|
|
|
+ if (graph.isEnabled())
|
|
|
+ {
|
|
|
+ td = document.createElement('td');
|
|
|
+ td.style.textAlign = 'center';
|
|
|
+
|
|
|
+ var cb2 = document.createElement('input');
|
|
|
+ cb2.setAttribute('type', 'checkbox');
|
|
|
+ cb2.style.marginRight = '8px';
|
|
|
+
|
|
|
+ cb2.defaultChecked = (selected != null && mxUtils.indexOf(selected, tag) >= 0);
|
|
|
+ cb2.checked = cb2.defaultChecked;
|
|
|
+ cb2.setAttribute('title', mxResources.get(
|
|
|
+ cb2.defaultChecked ? 'removeIt' : 'add',
|
|
|
+ ['']));
|
|
|
+
|
|
|
+ if (selected == null)
|
|
|
+ {
|
|
|
+ cb2.setAttribute('disabled', 'disabled');
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ mxEvent.addListener(cb2, 'change', function(evt)
|
|
|
+ {
|
|
|
+ if (cb2.checked)
|
|
|
+ {
|
|
|
+ graph.addTagsForCells(graph.getSelectionCells(), [tag]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ graph.removeTagsForCells(graph.getSelectionCells(), [tag]);
|
|
|
+ }
|
|
|
+
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ td.appendChild(cb2);
|
|
|
+ row.appendChild(td);
|
|
|
+ }
|
|
|
+
|
|
|
+ td = document.createElement('td');
|
|
|
+
|
|
|
+ a = document.createElement('a');
|
|
|
+ mxUtils.write(a, tag);
|
|
|
+ a.setAttribute('title', mxResources.get('selectAll') +
|
|
|
+ ' (' + tag + ')');
|
|
|
+ a.style.textOverflow = 'ellipsis';
|
|
|
+ a.style.position = 'relative';
|
|
|
+ a.style.cursor = 'pointer';
|
|
|
+ a.style.top = '-1px';
|
|
|
+ td.appendChild(a);
|
|
|
+
|
|
|
+ mxEvent.addListener(a, 'click', (function()
|
|
|
+ {
|
|
|
+ return function(evt)
|
|
|
+ {
|
|
|
+ if (!cb.checked)
|
|
|
+ {
|
|
|
+ cb.click();
|
|
|
+ }
|
|
|
+
|
|
|
+ var cells = graph.getCellsForTags(
|
|
|
+ [tag], null, null, true);
|
|
|
+
|
|
|
+ if (graph.isEnabled())
|
|
|
+ {
|
|
|
+ graph.setSelectionCells(cells);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ graph.highlightCells(cells);
|
|
|
+ }
|
|
|
+
|
|
|
+ mxEvent.consume(evt);
|
|
|
+ };
|
|
|
+ })());
|
|
|
+
|
|
|
+ row.appendChild(td);
|
|
|
+ tbody.appendChild(row);
|
|
|
+ })(tags[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ table.appendChild(tbody);
|
|
|
+ tagCloud.appendChild(table);
|
|
|
}
|
|
|
- else
|
|
|
+
|
|
|
+ refreshButtons();
|
|
|
+ };
|
|
|
+
|
|
|
+ var refreshUi = mxUtils.bind(this, function()
|
|
|
+ {
|
|
|
+ if (this.window.isVisible())
|
|
|
{
|
|
|
- for (var i = 0; i < cells.length; i++)
|
|
|
+ var tags = graph.getAllTags();
|
|
|
+
|
|
|
+ if (removeCb.checked)
|
|
|
+ {
|
|
|
+ allTags = tags;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ for (var i = 0; i < tags.length; i++)
|
|
|
+ {
|
|
|
+ if (mxUtils.indexOf(allTags, tags[i]) < 0)
|
|
|
+ {
|
|
|
+ allTags.push(tags[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ allTags.sort();
|
|
|
+
|
|
|
+ if (graph.isSelectionEmpty())
|
|
|
{
|
|
|
- graph.highlightCell(cells[i]);
|
|
|
+ refreshTags(allTags);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ refreshTags(allTags, graph.getCommonTagsForCells(
|
|
|
+ graph.getSelectionCells()));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
- showBtn.setAttribute('title', mxResources.get('show'));
|
|
|
- showBtn.style.marginTop = '8px';
|
|
|
- showBtn.style.marginRight = '4px';
|
|
|
- showBtn.className = 'geBtn';
|
|
|
-
|
|
|
- div.appendChild(showBtn);
|
|
|
-
|
|
|
- var action = editorUi.actions.get('tags');
|
|
|
|
|
|
- var btn = mxUtils.button(mxResources.get('close'), function()
|
|
|
+ graph.selectionModel.addListener(mxEvent.EVENT_CHANGE, refreshUi);
|
|
|
+ graph.model.addListener(mxEvent.EVENT_CHANGE, refreshUi);
|
|
|
+ graph.addListener(mxEvent.REFRESH, refreshUi);
|
|
|
+
|
|
|
+ var footer = document.createElement('div');
|
|
|
+ footer.style.boxSizing = 'border-box';
|
|
|
+ footer.style.position = 'absolute';
|
|
|
+ footer.style.userSelect = 'none';
|
|
|
+ footer.style.bottom = '0px';
|
|
|
+ footer.style.height = '42px';
|
|
|
+ footer.style.right = '10px';
|
|
|
+ footer.style.left = '10px';
|
|
|
+
|
|
|
+ // TODO: Write help topic and add link
|
|
|
+ /*
|
|
|
+ var helpBtn = mxUtils.button(mxResources.get('help'), function()
|
|
|
{
|
|
|
- action.funct();
|
|
|
+ editorUi.openLink('');
|
|
|
});
|
|
|
+
|
|
|
+ helpBtn.className = 'geBtn';
|
|
|
+ helpBtn.style.marginRight = '4px';
|
|
|
|
|
|
- btn.setAttribute('title', mxResources.get('close') + ' (Enter/Esc)');
|
|
|
- btn.style.marginTop = '8px';
|
|
|
- btn.className = 'geBtn gePrimaryBtn';
|
|
|
+ if (editorUi.isOffline() && !mxClient.IS_CHROMEAPP)
|
|
|
+ {
|
|
|
+ helpBtn.style.display = 'none';
|
|
|
+ }
|
|
|
|
|
|
- div.appendChild(btn);
|
|
|
-
|
|
|
- mxEvent.addListener(searchInput, 'keyup', function(evt)
|
|
|
+ footer.appendChild(helpBtn);*/
|
|
|
+
|
|
|
+ if (graph.isEnabled())
|
|
|
{
|
|
|
- // Ctrl or Cmd keys
|
|
|
- if (evt.keyCode == 13 || evt.keyCode == 27)
|
|
|
- {
|
|
|
- action.funct();
|
|
|
- }
|
|
|
- });
|
|
|
+ footer.appendChild(addBtn);
|
|
|
+ }
|
|
|
+
|
|
|
+ div.appendChild(footer);
|
|
|
|
|
|
this.window = new mxWindow(mxResources.get('tags'), div, x, y, w, h, true, true);
|
|
|
this.window.destroyOnClose = false;
|
|
|
this.window.setMaximizable(false);
|
|
|
- this.window.setResizable(false);
|
|
|
+ this.window.setResizable(true);
|
|
|
this.window.setClosable(true);
|
|
|
-
|
|
|
+
|
|
|
+ this.window.contentWrapper.style.height = '100%';
|
|
|
+ this.window.table.style.minHeight = '40px';
|
|
|
+ this.window.table.style.minWidth = '200px';
|
|
|
+ this.window.div.style.minHeight = this.window.table.style.minHeight;
|
|
|
+ this.window.div.style.minWidth = this.window.table.style.minWidth;
|
|
|
+
|
|
|
this.window.addListener('show', mxUtils.bind(this, function()
|
|
|
{
|
|
|
+ refreshUi();
|
|
|
this.window.fit();
|
|
|
-
|
|
|
- if (this.window.isVisible())
|
|
|
- {
|
|
|
- searchInput.focus();
|
|
|
-
|
|
|
- if (mxClient.IS_GC || mxClient.IS_FF || document.documentMode >= 5)
|
|
|
- {
|
|
|
- searchInput.select();
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- document.execCommand('selectAll', false, null);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- graph.container.focus();
|
|
|
- }
|
|
|
}));
|
|
|
|
|
|
this.window.setLocation = function(x, y)
|