import Editor from 'tinymce/core/api/Editor'; import Env from 'tinymce/core/api/Env'; import Tools from 'tinymce/core/api/util/Tools'; import * as Options from '../api/Options'; const getPreviewHtml = (editor: Editor): string => { let headHtml = ''; const encode = editor.dom.encode; const contentStyle = Options.getContentStyle(editor) ?? ''; headHtml += ''; const cors = Options.shouldUseContentCssCors(editor) ? ' crossorigin="anonymous"' : ''; Tools.each(editor.contentCSS, (url) => { headHtml += ''; }); if (contentStyle) { headHtml += ''; } const bodyId = Options.getBodyId(editor); const bodyClass = Options.getBodyClass(editor); const isMetaKeyPressed = Env.os.isMacOS() || Env.os.isiOS() ? 'e.metaKey' : 'e.ctrlKey && !e.altKey'; const preventClicksOnLinksScript = ( ' ' ); const directionality = editor.getBody().dir; const dirAttr = directionality ? ' dir="' + encode(directionality) + '"' : ''; const previewHtml = ( '' + '' + '' + headHtml + '' + '' + editor.getContent() + preventClicksOnLinksScript + '' + '' ); return previewHtml; }; export { getPreviewHtml };