Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Commit

Permalink
fix(properties-panel): make sure to always paste as plain text
Browse files Browse the repository at this point in the history
  • Loading branch information
barmac authored and fake-join[bot] committed Mar 11, 2020
1 parent e2ffe55 commit f3b16a9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/PropertiesPanel.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,16 @@ PropertiesPanel.prototype._bindListeners = function(container) {
domDelegate.bind(container, 'input, textarea, [contenteditable]', 'input', debounce(handleChange, DEBOUNCE_DELAY));
domDelegate.bind(container, 'input, textarea, select, [contenteditable]', 'change', handleChange);

// paste as plain text only
domDelegate.bind(container, '[contenteditable]', 'paste', handlePaste);

function handlePaste(event) {
var text = (event.clipboardData || window.clipboardData).getData('text');
document.execCommand('insertText', false, text);

event.preventDefault();
}

domDelegate.bind(container, '[data-action]', 'click', function onClick(event) {

// triggers on all inputs
Expand Down
5 changes: 5 additions & 0 deletions test/spec/PropertiesPanelSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,10 @@ describe('properties-panel', function() {
});


describe('listeners', function() {

// Cannot be tested due to paste events not affecting document's contents per default.
// Cf. https://developer.mozilla.org/en-US/docs/Web/API/Element/paste_event
it('should paste to [contenteditable] as plain text');
});
});
9 changes: 9 additions & 0 deletions test/spec/properties/PropertiesProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,15 @@ function createGroups(element, cmmnFactory) {
}
}
]
},
{
id: 'inputs',
entries: [
{
id: 'contenteditable',
html: '<div>Content editable:<div contenteditable></div></div>'
}
]
}
];
}
Expand Down

0 comments on commit f3b16a9

Please sign in to comment.