AvocadoAmber/AvocadoEdition_Light/plugin/editor/smarteditor2/config.js
2024-09-22 15:53:38 +09:00

50 lines
2.1 KiB
JavaScript

(function ($) {
$(document).ready(function () {
$(".smarteditor2").each(function (index) {
var get_id = $(this).attr("id");
if (!get_id || $(this).prop("nodeName") != 'TEXTAREA') return true;
nhn.husky.EZCreator.createInIFrame({
oAppRef: oEditors,
elPlaceHolder: get_id,
sSkinURI: g5_editor_url + "/SmartEditor2Skin.html",
htParams: {
bUseToolbar: true,
bUseVerticalResizer: true,
bUseModeChanger: true,
bSkipXssFilter: true,
aAdditionalFontList: editorAdditionalFontList,
fOnBeforeUnload: function () {
// unload
}
}, //boolean
fOnAppLoad: function () {
const extraFont = document.head.querySelector('#extra_font');
if (extraFont) {
const fontStyle = extraFont.textContent || extraFont.innerText;
const editorDocument = oEditors.getById[get_id].getWYSIWYGDocument();
const editorHead = editorDocument.getElementsByTagName("head")[0];
const editorStyle = editorDocument.createElement("style");
editorStyle.appendChild(editorDocument.createTextNode(fontStyle));
editorHead.appendChild(editorStyle);
const iframes = document.getElementsByTagName('iframe');
for (let i = 0; i < iframes.length; i++) {
if (iframes[i].src.indexOf('SmartEditor2Skin.html') !== -1) {
const iframeDocument = iframes[i].contentDocument || iframes[i].contentWindow.document;
const iframeHead = iframeDocument.getElementsByTagName("head")[0];
if (!iframeHead.querySelector("#extra_font")) {
const iframeStyle = iframeDocument.createElement("style");
iframeStyle.id = "extra_font";
iframeStyle.appendChild(iframeDocument.createTextNode(fontStyle));
iframeHead.appendChild(iframeStyle);
}
}
}
}
},
fCreator: "createSEditor2"
});
});
});
})(jQuery);