1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 154× 154× 154× 154× 1× 154× 154× 154× 154× 154× 1× 154× 154× 154× 154× 154× 154× 154× 154× 1× 2× 1× 1× 1× 154× 154× 154× 154× 154× 154× 154× 154× 154× 154× 154× 124× 154× 3× 154× 3× 154× 154× 3× 154× 1× 1× 1× 4× 4× 7× 7× 4× 1× 154× 154× 1× 10270× 10270× 10237× 33× 10270× 1× 4078× 1× 1× | /* istanbul ignore next */ var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); define(["require", "exports", "../renderer/content-renderer", "@syncfusion/ej2-base", "../base/util", "../../common/editor-styles", "../base"], function (require, exports, content_renderer_1, ej2_base_1, util_1, editor_styles_1, base_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var IframeContentRender = (function (_super) { __extends(IframeContentRender, _super); function IframeContentRender() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.styles = _this.getEditorStyles(); _this.IFRAMEHEADER = "\n <!DOCTYPE html> \n <html>\n <head>\n <meta charset='utf-8' /> \n <style>" + _this.styles + "\n </style>\n </head>\n "; return _this; } IframeContentRender.prototype.getEditorStyles = function () { var baseStyles = editor_styles_1.IFRAME_EDITOR_STYLES.replace(/[\n\t]/g, ''); var themeStyle = window.getComputedStyle(this.parent.element.querySelector('.e-rte-container')); var isDarkTheme = themeStyle.content.includes('dark-theme'); var themeStyles = (isDarkTheme ? editor_styles_1.IFRAME_EDITOR_DARK_THEME_STYLES : editor_styles_1.IFRAME_EDITOR_LIGHT_THEME_STYLES).replace(/[\n\t]/g, ''); return baseStyles + themeStyles; }; IframeContentRender.prototype.renderPanel = function () { var rteObj = this.parent; var rteContent = util_1.getEditValue(rteObj.value, rteObj); var iFrameBodyContent = '<body contenteditable="true" aria-label="Rich Text Editor" role="textbox" lang="' + this.parent.locale.slice(0, 2) + '" dir="' + (this.parent.enableRtl ? 'rtl' : 'ltr') + '">' + rteContent + '</body></html>'; var iFrameContent = this.IFRAMEHEADER + iFrameBodyContent; var iframe = this.parent.createElement('iframe', { id: this.parent.getID() + '_rte-view', className: 'e-rte-content', attrs: { 'srcdoc': iFrameContent } }); iframe.setAttribute('role', 'none'); this.setPanel(iframe); if (!ej2_base_1.isNullOrUndefined(this.parent.iframeSettings.sandbox)) { var sandboxValues = this.parent.iframeSettings.sandbox .map(function (element) { return element.toLocaleLowerCase().trim(); }) .join(' '); Eif (!sandboxValues.includes('allow-same-origin')) { sandboxValues += ' allow-same-origin'; } iframe.setAttribute('sandbox', sandboxValues.trim()); } var iframeWrapper = ej2_base_1.createElement('div', { className: base_1.CLS_RTE_IFRAME_CONTENT }); rteObj.rootContainer.appendChild(iframeWrapper); iframeWrapper.appendChild(iframe); iframe.contentDocument.body.setAttribute('aria-owns', this.parent.getID()); iframe.contentDocument.open(); iFrameContent = this.setThemeColor(iFrameContent, { color: '#333' }); iframe.contentDocument.write(iFrameContent); iframe.contentDocument.close(); var body = iframe.contentDocument.body; body.className = 'e-content'; if (this.parent.height === 'auto') { body.style.overflowY = 'hidden'; } if (!ej2_base_1.isNullOrUndefined(this.parent.fontFamily.default)) { body.style.fontFamily = this.parent.fontFamily.default; } if (!ej2_base_1.isNullOrUndefined(this.parent.fontSize.default)) { body.style.fontSize = this.parent.fontSize.default; } body.id = this.parent.getID() + '_rte-edit-view'; if (rteObj.enableRtl) { this.contentPanel.contentDocument.body.classList.add('e-rtl'); } if (!ej2_base_1.isNullOrUndefined(iframe.contentDocument.head) && this.parent.iframeSettings.metaTags.length > 0) { var head_1 = iframe.contentDocument.head; var metaData = this.parent.iframeSettings.metaTags; metaData.forEach(function (tag) { var meta = document.createElement('meta'); for (var key in tag) { Eif (!ej2_base_1.isNullOrUndefined(tag[key])) { meta.setAttribute((key === 'httpEquiv') ? 'http-equiv' : key, tag[key]); } } head_1.appendChild(meta); }); } }; IframeContentRender.prototype.setThemeColor = function (content, styles) { var fontColor = getComputedStyle(this.parent.element, '.e-richtexteditor').getPropertyValue('color'); return content.replace(styles.color, fontColor); }; IframeContentRender.prototype.getEditPanel = function () { var editNode; if (!ej2_base_1.isNullOrUndefined(this.contentPanel.contentDocument)) { editNode = this.contentPanel.contentDocument.body; } else { editNode = this.parent.inputElement; } return editNode; }; IframeContentRender.prototype.getDocument = function () { return this.getEditPanel().ownerDocument; }; return IframeContentRender; }(content_renderer_1.ContentRender)); exports.IframeContentRender = IframeContentRender; }); |