fix: Edit view — white default bg, paste formatting, text-align + all styles whitelisted
This commit is contained in:
@@ -52,7 +52,7 @@
|
||||
<div class="mb-3">
|
||||
<label asp-for="BackgroundColor" class="form-label">Background Colour</label>
|
||||
<div class="input-group">
|
||||
<input type="color" id="bgColorPicker" class="form-control form-control-color" value="@(Model.BackgroundColor ?? "#1a1a2e")" />
|
||||
<input type="color" id="bgColorPicker" class="form-control form-control-color" value="@(Model.BackgroundColor ?? "#ffffff")" />
|
||||
<input asp-for="BackgroundColor" class="form-control" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -105,6 +105,20 @@
|
||||
selector: '#contentEditor',
|
||||
height: 500,
|
||||
license_key: 'gpl',
|
||||
paste_data_images: true,
|
||||
paste_webkit_styles: 'all',
|
||||
paste_postprocess: function(editor, args) {
|
||||
args.node.querySelectorAll('*').forEach(function(el) {
|
||||
var tag = el.tagName.toLowerCase();
|
||||
var isTablePart = (tag === 'td' || tag === 'th' || tag === 'table' || tag === 'tr');
|
||||
if (el.style.color && !isTablePart) el.style.color = '#000';
|
||||
if (el.style.backgroundColor && !isTablePart) el.style.backgroundColor = '';
|
||||
});
|
||||
},
|
||||
valid_styles: {
|
||||
'*': 'color,background-color,background,font-size,font-family,text-align,text-decoration,font-weight,font-style,border,border-color,border-width,border-style,border-collapse,padding,padding-left,padding-right,padding-top,padding-bottom,margin,margin-left,margin-right,margin-top,margin-bottom,width,height,max-width,max-height,min-width,min-height,vertical-align,white-space,display,float,line-height,letter-spacing,text-indent,text-transform,list-style-type,opacity'
|
||||
},
|
||||
extended_valid_elements: 'table[*],tr[*],td[*],th[*],colgroup[*],col[*],thead[*],tbody[*],tfoot[*],div[*],span[*],p[*],img[*],a[*],h1[*],h2[*],h3[*],h4[*],h5[*],h6[*]',
|
||||
menubar: 'file edit view insert format table',
|
||||
plugins: 'advlist autolink lists link image charmap preview anchor searchreplace visualblocks code fullscreen insertdatetime media table help wordcount',
|
||||
toolbar: 'undo redo | blocks fontsize | bold italic forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | image media table | removeformat code fullscreen',
|
||||
|
||||
Reference in New Issue
Block a user