Skip to content

Commit 25c851e

Browse files
authored
enh(ui): Mon 152223 impossible to delete an element on a map (#175)
* copy/paste from web, editableContent cleanup text * run build webapp
1 parent 7b65cd4 commit 25c851e

File tree

7 files changed

+3283
-3260
lines changed

7 files changed

+3283
-3260
lines changed

src/main/webapp/js/app.min.js

Lines changed: 606 additions & 607 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/js/diagramly/EditorUi.js

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10755,12 +10755,11 @@
1075510755
{
1075610756
// No dialog visible
1075710757
var source = mxEvent.getSource(evt);
10758-
1075910758
if (graph.container != null && graph.isEnabled() && !graph.isMouseDown && !graph.isEditing() &&
1076010759
this.dialog == null && source.nodeName != 'INPUT' && source.nodeName != 'TEXTAREA')
1076110760
{
1076210761
if (evt.keyCode == 224 /* FF */ || (!mxClient.IS_MAC && evt.keyCode == 17 /* Control */) ||
10763-
(mxClient.IS_MAC && (evt.keyCode == 91 || evt.keyCode == 93) /* Left/Right Meta */))
10762+
(mxClient.IS_MAC && (evt.keyCode == 91 || evt.keyCode == 93) /* Left/Right Meta */))
1076410763
{
1076510764
// Cannot use parentNode for check in IE
1076610765
if (!restoreFocus)
@@ -10773,7 +10772,7 @@
1077310772

1077410773
graph.container.appendChild(textInput);
1077510774
restoreFocus = true;
10776-
10775+
1077710776
textInput.focus();
1077810777
document.execCommand('selectAll', false, null);
1077910778

@@ -10783,8 +10782,43 @@
1078310782
}
1078410783
}
1078510784
}
10786-
}));
1078710785

10786+
// Get the closest ancestor with class names 'mxCellEditor' and 'geContentEditable'
10787+
var sourceEditable = source.closest('.mxCellEditor.geContentEditable');
10788+
if (sourceEditable) {
10789+
// Handle paste event for Ctrl+V or right-click+paste
10790+
mxEvent.addListener(sourceEditable, 'paste', mxUtils.bind(this, function(ev) {
10791+
if (
10792+
source.nodeName == 'DIV' &&
10793+
graph.container != null &&
10794+
graph.isEnabled() &&
10795+
graph.isEditing() &&
10796+
this.dialog == null &&
10797+
!graph.isCellLocked(graph.getDefaultParent())
10798+
) {
10799+
10800+
if (ev.clipboardData != null) {
10801+
// Clean up HTML tags and take only the string content
10802+
this.pasteCells(ev, sourceEditable, true, true, true);
10803+
}
10804+
10805+
if (!mxEvent.isConsumed(ev)) {
10806+
var x0 = graph.container.scrollLeft;
10807+
var y0 = graph.container.scrollTop;
10808+
10809+
window.setTimeout(mxUtils.bind(this, function() {
10810+
// Workaround for Safari 16 scroll after paste
10811+
graph.container.scrollLeft = x0;
10812+
graph.container.scrollTop = y0;
10813+
10814+
this.pasteCells(ev, textInput, false, true);
10815+
}), 0);
10816+
}
10817+
}
10818+
}), true);
10819+
}
10820+
10821+
}));
1078810822
// Clears input and restores focus and selection
1078910823
function clearInput()
1079010824
{
@@ -10815,7 +10849,7 @@
1081510849
graph.container.focus();
1081610850
}
1081710851

10818-
textInput.parentNode.removeChild(textInput);
10852+
textInput.parentNode?.removeChild?.(textInput);
1081910853

1082010854
// Workaround for lost cursor in focused element
1082110855
if (this.dialog == null)
@@ -13245,7 +13279,7 @@
1324513279
/**
1324613280
* Creates the format panel and adds overrides.
1324713281
*/
13248-
EditorUi.prototype.pasteCells = function(evt, realElt, useEvent, pasteAsLabel)
13282+
EditorUi.prototype.pasteCells = function(evt, realElt, useEvent, pasteAsLabel, externalPaste=false)
1324913283
{
1325013284
if (!mxEvent.isConsumed(evt))
1325113285
{
@@ -13290,9 +13324,8 @@
1329013324
mxUtils.setTextContent(elt, data);
1329113325
}
1329213326
}
13293-
13327+
1329413328
var spans = elt.getElementsByTagName('span');
13295-
1329613329
if (spans != null && spans.length > 0 && spans[0].getAttribute('data-lucid-type') ===
1329713330
'application/vnd.lucid.chart.objects')
1329813331
{
@@ -13414,7 +13447,14 @@
1341413447
}
1341513448
else
1341613449
{
13417-
this.pasteXml(xml, pasteAsLabel, compat, evt);
13450+
if (externalPaste) {
13451+
var parsePlain = new DOMParser().parseFromString(plain, 'text/html');
13452+
plain = parsePlain?.body?.textContent || plain;
13453+
mxUtils.setTextContent(realElt, plain);
13454+
}
13455+
else {
13456+
this.pasteXml(xml, pasteAsLabel, compat, evt);
13457+
}
1341813458
}
1341913459

1342013460
try
@@ -13440,8 +13480,9 @@
1344013480
}
1344113481
}
1344213482
}
13443-
13444-
realElt.innerHTML = ' ';
13483+
if (!externalPaste) {
13484+
realElt.innerHTML = ' ';
13485+
}
1344513486
};
1344613487

1344713488
/**

src/main/webapp/js/extensions.min.js

Lines changed: 7 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/js/integrate.min.js

Lines changed: 571 additions & 578 deletions
Large diffs are not rendered by default.

src/main/webapp/js/orgchart.min.js

Lines changed: 1 addition & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/js/viewer-static.min.js

Lines changed: 1023 additions & 1026 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main/webapp/js/viewer.min.js

Lines changed: 1023 additions & 1026 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)