|
17 | 17 | addEventListener('rl-view-model', e => { |
18 | 18 | const vm = e.detail; |
19 | 19 | if ('PopupsCompose' === vm.viewModelTemplateID && rl.settings.get('editorWysiwyg') === 'CompactComposer') { |
20 | | - vm.querySelector('.tabs label[for="tab-body"]').dataset.bind = "visible: canMailvelope"; |
| 20 | + // add visible binding to the label |
| 21 | + const bodyLabel = vm.querySelector('.tabs label[for="tab-body"]'); |
| 22 | + bodyLabel.dataset.bind = 'visible: canMailvelope'; |
| 23 | + // re-apply the binding |
| 24 | + const labelNext = bodyLabel.nextElementSibling; |
| 25 | + ko.removeNode(bodyLabel); |
| 26 | + labelNext.parentElement.insertBefore(bodyLabel, labelNext); |
| 27 | + ko.applyBindingAccessorsToNode(bodyLabel, null, vm); |
| 28 | + |
21 | 29 | // Now move the attachments tab to the bottom of the screen |
22 | | - const |
23 | | - input = vm.querySelector('.tabs input[value="attachments"]'), |
24 | | - label = vm.querySelector('.tabs label[for="tab-attachments"]'), |
25 | | - area = vm.querySelector('.tabs .attachmentAreaParent'); |
26 | | - input.remove(); |
27 | | - label.remove(); |
28 | | - area.remove(); |
| 30 | + const area = vm.querySelector('.tabs .attachmentAreaParent'); |
| 31 | + vm.querySelector('.tabs input[value="attachments"]').remove(); |
| 32 | + vm.querySelector('.tabs label[for="tab-attachments"]').remove(); |
| 33 | + area.querySelector('.no-attachments-desc').remove(); |
29 | 34 | area.classList.add('compact'); |
30 | | - area.querySelector('.b-attachment-place').dataset.bind = "visible: addAttachmentEnabled(), css: {dragAndDropOver: dragAndDropVisible}"; |
31 | 35 | vm.viewModelDom.append(area); |
| 36 | + // Add and re-apply the bindings for the attachment-place |
| 37 | + const place = area.querySelector('.b-attachment-place'); |
| 38 | + ko.removeNode(place); |
| 39 | + area.insertBefore(place, area.firstElementChild); |
| 40 | + place.dataset.bind = 'visible: addAttachmentEnabled(), css: {dragAndDropOver: dragAndDropVisible}'; |
| 41 | + ko.applyBindingAccessorsToNode(place, null, vm); |
32 | 42 | // There is a better way to do this probably, |
33 | 43 | // but we need this for drag and drop to work |
34 | 44 | e.detail.attachmentsArea = e.detail.bodyArea; |
35 | 45 | } |
36 | 46 | }); |
37 | 47 |
|
38 | 48 | const |
39 | | - removeElements = 'HEAD,LINK,META,NOSCRIPT,SCRIPT,TEMPLATE,TITLE', |
40 | | - allowedElements = 'A,B,BLOCKQUOTE,BR,DIV,EM,FONT,H1,H2,H3,H4,H5,H6,HR,I,IMG,LI,OL,P,SPAN,STRONG,TABLE,TD,TH,TR,U,UL', |
41 | | - allowedAttributes = 'abbr,align,background,bgcolor,border,cellpadding,cellspacing,class,color,colspan,dir,face,frame,height,href,hspace,id,lang,rowspan,rules,scope,size,src,style,target,type,usemap,valign,vspace,width'.split(','), |
42 | | - |
43 | 49 | // TODO: labels translations |
44 | 50 | i18n = (str, def) => rl.i18n(str) || def, |
45 | 51 |
|
|
95 | 101 | }, |
96 | 102 |
|
97 | 103 | pasteSanitizer = (event) => { |
98 | | - const frag = event.detail.fragment; |
99 | | - frag.querySelectorAll('a:empty,span:empty').forEach(el => el.remove()); |
100 | | - frag.querySelectorAll(removeElements).forEach(el => el.remove()); |
101 | | - frag.querySelectorAll('*').forEach(el => { |
102 | | - if (!el.matches(allowedElements)) { |
103 | | - el.replaceWith(getFragmentOfChildren(el)); |
104 | | - } else if (el.hasAttributes()) { |
105 | | - [...el.attributes].forEach(attr => { |
106 | | - let name = attr.name.toLowerCase(); |
107 | | - if (!allowedAttributes.includes(name)) { |
108 | | - el.removeAttribute(name); |
109 | | - } |
110 | | - }); |
111 | | - } |
112 | | - }); |
| 104 | + return rl.Utils.cleanHtml(event.detail.html).html; |
113 | 105 | }, |
114 | 106 |
|
115 | 107 | pasteImageHandler = (e, squire) => { |
|
317 | 309 | clr.style.left = (input.offsetLeft + input.parentNode.offsetLeft) + 'px'; |
318 | 310 | clr.style.width = input.offsetWidth + 'px'; |
319 | 311 |
|
320 | | - clr.value = ''; |
| 312 | + // firefox does not call "onchange" for #000 if we use clr.value='' |
| 313 | + clr.value = '#00ff0c'; |
321 | 314 | clr.onchange = () => { |
322 | 315 | switch (name) { |
323 | 316 | case 'color': |
|
0 commit comments