(function () { CKEDITOR.plugins.add("customheader", { init: function (editor) { editor.ui.addButton("DocumentName", { label: "문서명", command: "copyLink", toolbar: "customheader,1", icon: "copy" }); editor.addCommand("copyLink", { readOnly: 1, exec: function () { var link = location.origin + location.pathname + "?page=adms&pdServiceId=" + $("#selected_pdService").val() + "&wikiId=" + $("#wiki_tree").jstree("get_selected").attr("id").replace("node_", "").replace("copy_", ""); if (typeof navigator.clipboard == "undefined") { var textArea = document.createElement("textarea"); textArea.value = link; textArea.style.position = "fixed"; document.body.appendChild(textArea); textArea.focus(); textArea.select(); document.execCommand("copy"); document.body.removeChild(textArea); return; } navigator.clipboard.writeText(link); } }); editor.addCommand("selectDocument", { readOnly: 1, exec: function (_, docName) { console.log("docName ==> ", docName); var docLabel = editor.container.findOne(".cke_button__documentname_label"); if (docLabel) { docLabel.setText(docName); } } }); } }); })();