Skip to content

Commit d8183fe

Browse files
DinuRothMartin Roth
andauthored
only use the designated fragment when pasting html into a RadzenHtmlEditor (#2285)
* only use the designated fragment when pasting html into a RadzenHtmlEditor * fragment-extraction inlined --------- Co-authored-by: Martin Roth <[email protected]>
1 parent e49fe2b commit d8183fe

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Radzen.Blazor/wwwroot/Radzen.Blazor.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2011,6 +2011,18 @@ window.Radzen = {
20112011
} else if (paste) {
20122012
e.preventDefault();
20132013
var data = e.clipboardData.getData('text/html') || e.clipboardData.getData('text/plain');
2014+
2015+
const startMarker = "<!--StartFragment-->";
2016+
const endMarker = "<!--EndFragment-->";
2017+
2018+
const startIndex = data.indexOf(startMarker);
2019+
const endIndex = data.indexOf(endMarker);
2020+
2021+
// check if the pasted data contains fragment markers
2022+
if (startIndex != -1 || endIndex != -1 || endIndex > startIndex) {
2023+
// only paste the fragment
2024+
data = data.substring(startIndex + startMarker.length, endIndex).trim();
2025+
}
20142026

20152027
instance.invokeMethodAsync('OnPaste', data)
20162028
.then(function (html) {

0 commit comments

Comments
 (0)