Hi,
I would like to use the paste service with something between plainText and keepFormat. I need plain text except for some allowed tags. For example if I try to copy a text from MS Word having a bold word and a table to allow only the bold format and use plain for the rest.
It's that possible somehow? I only see the deniedTags
thanks
|
<ejs-richtexteditor id='pasteCleanupRTE' #pasteCleanupRTE [pasteCleanupSettings]="pasteCleanupSettings"
(afterPasteCleanup)="afterPasteCleanup($event)">
<ng-template #valueTemplate>
...
</ng-template>
</ejs-richtexteditor> |
|
public pasteCleanupSettings: PasteCleanupSettingsModel = {
prompt: false,
plainText: false,
keepFormat: true
};
public afterPasteCleanup(e) {
var cloneElement = document.createElement('div');
cloneElement.innerHTML = e.value;
var pasteValue = '';
for (var i = 0; i < cloneElement.children.length; i++) {
if (cloneElement.children[i].tagName === 'TABLE') {
var row = (cloneElement.children[i] as HTMLTableElement).rows.length;
for (var j = 0; j < row; j++) {
var cell = (cloneElement.children[i] as HTMLTableElement).rows[j].cells.length;
for (var k = 0; k < cell; k++) {
var cellValue = (cloneElement.children[i] as HTMLTableElement).rows[j].cells.item(k).innerHTML;
pasteValue = pasteValue + cellValue;
}
}
} else {
pasteValue = pasteValue + cloneElement.children[i].outerHTML;
}
}
e.value = pasteValue;
} |
hmm I see but this will not scale easily if I want to clear format of more elements not only for tables, let's say for example if I want to exclude aslo underline or listed items I'll need to do it one by one.
An allowedTags property would be something nice to have.
thanks anywise
|
public afterPasteCleanup(e) {
var removeNodes = 'table, ul ,ol';
var cloneElement = document.createElement('div');
cloneElement.innerHTML = e.value;
var pasteValue = '';
. . . } |