(function () {
    if (window.RTE_DefaultConfig) {
        if (!window.RTE_DefaultConfig.imageItems) {
            window.RTE_DefaultConfig.imageItems = [];
        }
        if (!window.RTE_DefaultConfig.galleryImages) {
            window.RTE_DefaultConfig.galleryImages = [];
        }
        if (!window.RTE_DefaultConfig.htmlTemplates) {
            window.RTE_DefaultConfig.htmlTemplates = [];
        }

        var c = window.RTE_DefaultConfig;

        // Core defaults (must be set before editor initialization)
        if (!c.tooltipAttribute) c.tooltipAttribute = "rte-tooltip";
        if (!c.zIndexFullPage) c.zIndexFullPage = "9999";
        if (!c.zIndexFloat) c.zIndexFloat = "99999";
        if (!c.zIndexDialog) c.zIndexDialog = "999999";
        if (!c.zIndexDropDown) c.zIndexDropDown = "9999999";

        if (c.editablePaddingTop == null) c.editablePaddingTop = 2;
        if (c.editablePaddingBottom == null) c.editablePaddingBottom = 2;
        if (c.editablePaddingLeft == null) c.editablePaddingLeft = 2;
        if (c.editablePaddingRight == null) c.editablePaddingRight = 2;

        if (!c.fontNameDropDownMinWidth) c.fontNameDropDownMinWidth = "90px";
        if (!c.fontNameDropDownMaxWidth) c.fontNameDropDownMaxWidth = "140px";

        if (c.timeoutAddToUndo == null) c.timeoutAddToUndo = 900;
        if (!c.skin) c.skin = "default";
        if (!c.toolbar) c.toolbar = "default";
        if (!c.toolbarMobile) c.toolbarMobile = "mobile";
        if (c.maxWidthForMobile == null) c.maxWidthForMobile = 992;

        if (!c.urlType) c.urlType = "default";
        if (c.enableDragDrop == null) c.enableDragDrop = true;
        if (c.enableObjectResizing == null) c.enableObjectResizing = true;
        if (c.toggleBorder == null) c.toggleBorder = false;
        if (c.readOnly == null) c.readOnly = false;

        if (!c.editorResizeMode) c.editorResizeMode = "both";
        if (c.showPlusButton == null) c.showPlusButton = true;
        if (c.showTagList == null) c.showTagList = true;
        if (c.showStatistics == null) c.showStatistics = true;
        if (c.showSelectedBlock == null) c.showSelectedBlock = true;
        if (c.focusOnLoad == null) c.focusOnLoad = false;
        if (c.allowScriptCode == null) c.allowScriptCode = false;
        if (c.showFloatTextToolBar == null) c.showFloatTextToolBar = false;
        if (c.showFloatLinkToolBar == null) c.showFloatLinkToolBar = true;
        if (c.showFloatImageToolBbar == null) c.showFloatImageToolBbar = true;
        if (c.showFloatTableToolBar == null) c.showFloatTableToolBar = true;
        if (c.showFloatParagraph == null) c.showFloatParagraph = true;
        if (c.maxHTMLLength == null) c.maxHTMLLength = 0;
        if (c.maxTextLength == null) c.maxTextLength = 0;
        if (!c.tagWhiteList) c.tagWhiteList = [];
        if (!c.tagBlackList) c.tagBlackList = [];

        if (c.tabSpaces == null) c.tabSpaces = 4;
        if (!c.enterKeyTag) c.enterKeyTag = "p";
        if (!c.pasteMode) c.pasteMode = "Auto";

        if (!c.floatParagraphPos) c.floatParagraphPos = "left";
        if (c.floatParagraphPosX == null) c.floatParagraphPosX = 0;
        if (c.floatParagraphPosY == null) c.floatParagraphPosY = 0;

        if (!c.contentCssText) c.contentCssText = "";
        if (!c.previewCssText) c.previewCssText = "";
        if (!c.editorBodyCssClass) c.editorBodyCssClass = "";
        if (!c.editorBodyCssText) c.editorBodyCssText = "";

        if (c.paragraphClass === undefined) c.paragraphClass = null;
        if (!c.insertTableTag) c.insertTableTag = "<table></table>";
        if (!c.insertRowTag) c.insertRowTag = "<tr></tr>";
        if (!c.insertCellTag) c.insertCellTag = "<td><br/></td>";

        if (!c.insertOrderedListItems) c.insertOrderedListItems = [["decimal", "1,2,3,4,5"], ["lower-alpha", "a,b,c,d,e"], ["upper-alpha", "A,B,C,D,E"], ["lower-roman", "\u2170,\u2171,\u2172,\u2173,\u2174"], ["upper-roman", "\u2160,\u2161,\u2162\u2162,\u2163,\u2164"]];
        if (!c.insertUnorderedListItems) c.insertUnorderedListItems = [["disc", "Disc"], ["circle", "Circle"], ["square", "Square"]];

        if (!c.fontSizeItems) c.fontSizeItems = "8,9,10,11,12,13,14,16,18,24,36,48,60,72,96";
        if (!c.fontNameItems) c.fontNameItems = "Arial,Arial Black,Comic Sans MS,Courier New,Tahoma,Georgia,Helvetica, Segoe UI,Sans-Serif,Impact,Times New Roman,Verdana";
        if (!c.lineHeightItems) c.lineHeightItems = "100%,150%,200%,250%,300%,350%,400%,450%,500%,600%";
        if (!c.paragraphItems) c.paragraphItems = "Normal,H1,H2,H3,H4,H5,H6";

        if (!c.foreColorItems) c.foreColorItems = ["#000000", "#993300", "#333300", "#003300", "#003366", "#000080", "#333399", "#333333", "#800000", "#ff6600", "#808000", "#008000", "#008080", "#0000ff", "#666699", "#808080", "#ff0000", "#ff9900", "#99cc00", "#339966", "#33cccc", "#3366ff", "#800080", "#999999", "#ff00ff", "#ffcc00", "#ffff00", "#00ff00", "#00ffff", "#00ccff", "#993366", "#c0c0c0", "#ff99cc", "#ffcc99", "#ffff99", "#ccffcc", "#ccffff", "#99ccff", "#cc99ff", "#ffffff"];
        if (!c.backColorItems) c.backColorItems = ["#000000", "#993300", "#333300", "#003300", "#003366", "#000080", "#333399", "#333333", "#800000", "#ff6600", "#808000", "#008000", "#008080", "#0000ff", "#666699", "#808080", "#ff0000", "#ff9900", "#99cc00", "#339966", "#33cccc", "#3366ff", "#800080", "#999999", "#ff00ff", "#ffcc00", "#ffff00", "#00ff00", "#00ffff", "#00ccff", "#993366", "#c0c0c0", "#ff99cc", "#ffcc99", "#ffff99", "#ccffcc", "#ccffff", "#99ccff", "#cc99ff", "#ffffff"];

        if (!c.characterItems) c.characterItems = [
            { tab: "Unicode", items: ["&#402;", "&#913;", "&#914;", "&#915;", "&#916;", "&#917;", "&#918;", "&#919;", "&#920;", "&#921;", "&#922;", "&#923;", "&#924;", "&#925;", "&#926;", "&#927;", "&#928;", "&#929;", "&#931;", "&#932;", "&#933;", "&#934;", "&#935;", "&#936;", "&#937;", "&#945;", "&#946;", "&#947;", "&#948;", "&#949;", "&#950;", "&#951;", "&#952;", "&#953;", "&#954;", "&#955;", "&#956;", "&#957;", "&#958;", "&#959;", "&#960;", "&#961;", "&#962;", "&#963;", "&#964;", "&#965;", "&#966;", "&#967;", "&#968;", "&#969;", "&#977;", "&#978;", "&#982;", "&#8226;", "&#8230;", "&#8242;", "&#8243;", "&#8254;", "&#8260;", "&#8472;", "&#8465;", "&#8476;", "&#8482;", "&#8501;", "&#8592;", "&#8593;", "&#8594;", "&#8595;", "&#8596;", "&#8629;", "&#8656;", "&#8657;", "&#8658;", "&#8659;", "&#8660;", "&#8704;", "&#8706;", "&#8707;", "&#8709;", "&#8711;", "&#8712;", "&#8713;", "&#8715;", "&#8719;", "&#8722;", "&#8722;", "&#8727;", "&#8730;", "&#8733;", "&#8734;", "&#8736;", "&#8869;", "&#8870;", "&#8745;", "&#8746;", "&#8747;", "&#8756;", "&#8764;", "&#8773;", "&#8773;", "&#8800;", "&#8801;", "&#8804;", "&#8805;", "&#8834;", "&#8835;", "&#8836;", "&#8838;", "&#8839;", "&#8853;", "&#8855;", "&#8869;", "&#8901;", "&#8968;", "&#8969;", "&#8970;", "&#8971;", "&#9001;", "&#9002;", "&#9674;", "&#9824;", "&#9827;", "&#9829;", "&#9830;"] },
            { tab: "ASCII", from: 33, to: 126 },
            { tab: "European", from: 192, to: 255 },
            { tab: "Roma", from: 913, to: 1014 },
            { tab: "Webdings", font: "Webdings", from: 33, to: 255 },
            { tab: "Wingdings", font: "Wingdings", from: 33, to: 255 },
            { tab: "Symbol", font: "Symbol", from: 33, to: 255 }
        ];

        if (!c.linkItems) c.linkItems = ["https://www.intel.com", "https://www.ibm.com", "https://www.microsoft.com", "https://www.google.com", "https://www.apple.com"];

        if (!c.inlineStyles) c.inlineStyles = [
            ["Red marker", "color:red"],
            ["Blue marker", "color:blue"],
            ["Green marker", "color:green"],
            ["Yellow highlight", "background-color:yellow"],
            ["Big", "font-size:larger"],
            ["Small", "font-size:smaller"]
        ];
        if (!c.paragraphStyles) c.paragraphStyles = [
            ["Blue title", "color:blue;font-size:18px;font-weight:bold"],
            ["Red title", "color:red;font-size:18px;font-weight:bold"],
            ["Gray paragraph", "color:#666;border-left:3px solid #ccc;padding-left:10px"]
        ];
        if (!c.imageStyles) c.imageStyles = [
            ["Border", "border:1px solid #ccc;padding:2px"],
            ["Shadow", "box-shadow:0 2px 8px rgba(0,0,0,.2)"],
            ["Rounded", "border-radius:8px"]
        ];

        // Toolbar layout configs
        if (!c.toolbar_default) c.toolbar_default = "{bold,italic,underline,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,inserttodolist,indent,outdent,insertblockquote,insertemoji}"
            + " #{paragraphs:toggle,fontname:toggle,fontsize:toggle,inlinestyle,lineheight}"
            + " / {formatpainter,removeformat,cut,copy,paste,delete,find}|{insertlink,unlink,insertchars,inserttable,insertbookmark,insertimage,insertgallery,insertvideo,insertdocument,inserttemplate,insertcode}|{importword,exportword,exportpdf}"
            + "#{preview,code,selectall}"
            + " /{spellcheck,insertmergefield,insertfootnote,inserttoc,insertpagebreak}"
            + "#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}";

        if (!c.toolbar_mobile) c.toolbar_mobile = "{bold,italic,underline|fontname:toggle,fontsize:toggle,menu_paragraphop|forecolor,backcolor}"
            + "{insertlink,insertemoji,inserttable,insertimage,removeformat}"
            + "#{toggleborder,fullscreenenter,fullscreenexit,undo,redo,togglemore}";

        if (!c.toolbar_basic) c.toolbar_basic = "{bold,italic,underline}|{fontname,fontsize}|{insertlink,insertimage,insertemoji}|removeformat"
            + "#{undo,redo,togglemore}";

        if (!c.toolbar_full) c.toolbar_full = "{bold,italic,underline,linethrough,forecolor,backcolor}|{justifyleft,justifycenter,justifyright,justifyfull}|{insertorderedlist,insertunorderedlist,multilevellist,inserttodolist,indent,outdent}{superscript,subscript}"
            + " #{paragraphs:toggle,fontname:toggle,fontsize:toggle,inlinestyle,lineheight,casechange}"
            + " / {formatpainter,removeformat,cut,copy,paste,delete,find}|{insertlink,unlink,insertblockquote,insertemoji,insertchars,inserttable,insertbookmark,insertimage,insertgallery,insertvideo,insertdocument,inserttemplate,insertcode}"
            + "#{preview,code,selectall}"
            + " /{insertcomment,trackchanges,insertmention}|{importword,exportword,exportpdf}|{spellcheck,autoformatting,toggleborder}"
            + " /{paragraphs:dropdown | fontname:dropdown | fontsize:dropdown} {paragraphstyle,toggle_paragraphop,menu_paragraphop}"
            + "#{insertmergefield,insertfootnote,inserttoc,insertpagebreak,revisionhistory,fullscreenenter,fullscreenexit,undo,redo,togglemore}";

        if (!c.toolbar_office) c.toolbar_office = "<@COMMON,ribbonpaste,pastetext,pasteword,{save,new,print,spellcheck}{cut,copy,delete,find}{undo,redo|formatpainter}><@FORMAT,[fontname,fontsize]{bold,italic,underlinemenu|forecolor,backcolor}{superscript,subscript,changecase|removeformat,cleancode,selectall}><@PARAGRAPHS,[paragraphs,styles]{justifymenu,lineheight,ltr,rtl,insertlinemenu}{insertorderedlist,insertunorderedlist,indent,outdent,insertblockquote}><@INSERT,ribbontable,insertgallery,insertimage,{insertlink,unlink,insertanchor,insertdate,insertchars,insertemoji}{inserttemplate,insertdocument,insertvideo,insertcode}{toggleborder,fullscreen,help}><@REVIEW,{insertcomment,trackchanges,insertmention}{importword,exportword,exportpdf}{autoformatting,revisionhistory}>";

        if (!c.subtoolbar_more) c.subtoolbar_more = "{strike,superscript,subscript,ucase,lcase,inserthorizontalrule,html2pdf,insertdate} #{newdoc,load,save,print,help}";
        if (!c.subtoolbar_more_full) c.subtoolbar_more_full = "{strike,ucase,lcase,inserthorizontalrule,html2pdf,insertdate} #{newdoc,save,print,help}";
        if (!c.subtoolbar_more_mobile) c.subtoolbar_more_mobile = "{save} #{newdoc,help}";
        if (!c.subtoolbar_paste) c.subtoolbar_paste = "pasteauto,pastetext,pasteword";
        if (!c.subtoolbar_paragraphop) c.subtoolbar_paragraphop = "{justifyleft,justifycenter,justifyright,insertorderedlist,insertunorderedlist,indent,outdent,insertblockquote}";
        if (!c.subtoolbar_table) c.subtoolbar_table = "controlsizeauto,controlsize100,controlsize75,controlsize50,tabledelete";
        if (!c.subtoolbar_tablerow) c.subtoolbar_tablerow = "tablerowinsertabove,tablerowinsertbelow,tablerowdelete";
        if (!c.subtoolbar_tablecell) c.subtoolbar_tablecell = "tablecellmerge,tablecellsplitver,tablecellsplithor,tablecellforecolor,tablecellbackcolor";
        if (!c.subtoolbar_tablecolumn) c.subtoolbar_tablecolumn = "tablecolumninsertleft,tablecolumninsertright,tablecolumndelete";

        // Float toolbar definitions (context-sensitive toolbars for selected elements)
        if (!c.controltoolbar_TEXT) c.controltoolbar_TEXT = "removeformat | {bold,italic,underline,forecolordirect,backcolordirect}|{fontname:toggle,fontsize:toggle}|{insertlink}";
        if (!c.controltoolbar_A) c.controltoolbar_A = "{linkstyle,insertlink,unlink}";
        if (!c.controltoolbar_TD) c.controltoolbar_TD = "{tableheader,menu_tablecell,menu_tablerow,menu_tablecolumn,menu_table}";
        if (!c.controltoolbar_IMG) c.controltoolbar_IMG = "{menu_controlsize,imagecaption,controlalt,controlinsertlink,controleditlink,controlopenlink,controlunlink}/{menu_controljustify,imagestyle,imageeditor,delete}";

        // Float paragraph toolbar
        if (!c.subtoolbar_floatparagraph) c.subtoolbar_floatparagraph = "pmoveup,pmovedown,pduplicate,pdelete,pmore";

        // Toolbar SVG icons (outline style, viewBox 0 0 24 24)
        if (!c.svgCode_bold) c.svgCode_bold = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M7 5h6.5a3.5 3.5 0 0 1 0 7H7V5z" fill="currentColor" fill-opacity="0.15"/><path d="M7 12h7.5a3.5 3.5 0 0 1 0 7H7V12z" fill="currentColor" fill-opacity="0.15"/><path d="M7 5h6.5a3.5 3.5 0 0 1 0 7H7V5z"/><path d="M7 12h7.5a3.5 3.5 0 0 1 0 7H7V12z"/></svg>';
        if (!c.svgCode_italic) c.svgCode_italic = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="14" y1="5" x2="10" y2="19"/><line x1="10" y1="5" x2="17" y2="5"/><line x1="7" y1="19" x2="14" y2="19"/></svg>';
        if (!c.svgCode_underline) c.svgCode_underline = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M7 5v6a5 5 0 0 0 10 0V5"/><line x1="5" y1="21" x2="19" y2="21"/></svg>';
        if (!c.svgCode_linethrough) c.svgCode_linethrough = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="4" y1="12" x2="20" y2="12"/><path d="M15.5 7.5c-.4-1.5-2-2.5-3.5-2.5-2 0-3.5 1-3.5 2.5 0 1.2.8 2 2.5 2.5"/><path d="M8.5 16.5c.4 1.5 2 2.5 3.5 2.5 2 0 3.5-1 3.5-2.5 0-1.2-.8-2-2.5-2.5"/></svg>';
        if (!c.svgCode_superscript) c.svgCode_superscript = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 18L10.5 7"/><path d="M17 18L10.5 7"/><path d="M19 3c-.5 0-1 .5-1 1s.7 1.2 1.5 1.7c.8.5 1.5 1 1.5 1.8V8h-4"/></svg>';
        if (!c.svgCode_subscript) c.svgCode_subscript = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 18L10.5 7"/><path d="M17 18L10.5 7"/><path d="M19 14c-.5 0-1 .5-1 1s.7 1.2 1.5 1.7c.8.5 1.5 1 1.5 1.8V19h-4"/></svg>';
        if (!c.svgCode_justifyleft) c.svgCode_justifyleft = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="18" x2="9" y2="18"/></svg>';
        if (!c.svgCode_justifycenter) c.svgCode_justifycenter = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="6" y1="12" x2="18" y2="12"/><line x1="9" y1="18" x2="15" y2="18"/></svg>';
        if (!c.svgCode_justifyright) c.svgCode_justifyright = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="9" y1="12" x2="21" y2="12"/><line x1="15" y1="18" x2="21" y2="18"/></svg>';
        if (!c.svgCode_justifyfull) c.svgCode_justifyfull = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>';
        if (!c.svgCode_insertorderedlist) c.svgCode_insertorderedlist = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><text x="4" y="8" font-size="6" font-family="sans-serif" fill="currentColor" stroke="none" text-anchor="middle">1</text><text x="4" y="14" font-size="6" font-family="sans-serif" fill="currentColor" stroke="none" text-anchor="middle">2</text><text x="4" y="20" font-size="6" font-family="sans-serif" fill="currentColor" stroke="none" text-anchor="middle">3</text></svg>';
        if (!c.svgCode_insertunorderedlist) c.svgCode_insertunorderedlist = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="10" y1="6" x2="21" y2="6"/><line x1="10" y1="12" x2="21" y2="12"/><line x1="10" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_indent) c.svgCode_indent = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="19" x2="21" y2="19"/><line x1="11" y1="9" x2="21" y2="9"/><line x1="11" y1="12" x2="21" y2="12"/><line x1="11" y1="15" x2="21" y2="15"/><polyline points="3 8 7 12 3 16"/></svg>';
        if (!c.svgCode_outdent) c.svgCode_outdent = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="5" x2="21" y2="5"/><line x1="3" y1="19" x2="21" y2="19"/><line x1="11" y1="9" x2="21" y2="9"/><line x1="11" y1="12" x2="21" y2="12"/><line x1="11" y1="15" x2="21" y2="15"/><polyline points="7 8 3 12 7 16"/></svg>';
        if (!c.svgCode_insertlink) c.svgCode_insertlink = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.07.5l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.07-.5l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/></svg>';
        if (!c.svgCode_unlink) c.svgCode_unlink = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 13a5 5 0 0 0 7.07.5l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71"/><path d="M14 11a5 5 0 0 0-7.07-.5l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71"/><line x1="4" y1="20" x2="20" y2="4"/></svg>';
        if (!c.svgCode_insertblockquote) c.svgCode_insertblockquote = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 12V8c0-2.2 1.8-4 4-4h1"/><path d="M4 12h3a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2 2 2 0 0 1-2-2"/><path d="M13 12V8c0-2.2 1.8-4 4-4h1"/><path d="M13 12h3a2 2 0 0 1 2 2v1a2 2 0 0 1-2 2 2 2 0 0 1-2-2"/></svg>';
        if (!c.svgCode_inserttable) c.svgCode_inserttable = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="13" x2="21" y2="13"/><line x1="3" y1="17" x2="21" y2="17"/><line x1="9" y1="5" x2="9" y2="19"/><line x1="15" y1="5" x2="15" y2="19"/></svg>';
        if (!c.svgCode_insertimage) c.svgCode_insertimage = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="16" rx="2"/><circle cx="8.5" cy="9.5" r="1.5"/><polyline points="21 15 16 10 5 20"/></svg>';
        if (!c.svgCode_insertgallery) c.svgCode_insertgallery = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="6" y="2" width="16" height="14" rx="2"/><polyline points="22 11 18 7 10 16"/><circle cx="10" cy="6.5" r="1.5"/><path d="M2 6v14a2 2 0 0 0 2 2h14"/></svg>';
        if (!c.svgCode_insertvideo) c.svgCode_insertvideo = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="13" height="12" rx="1"/><polyline points="17 10 21 7 21 17 17 14"/></svg>';
        if (!c.svgCode_inserttemplate) c.svgCode_inserttemplate = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="8" y1="17" x2="8" y2="12"/><line x1="12" y1="17" x2="12" y2="9"/><line x1="16" y1="17" x2="16" y2="6"/></svg>';
        if (!c.svgCode_insertchars) c.svgCode_insertchars = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="18.5" cy="9.5" r="4.5"/><path d="M5 17.5c2 0 3.5-1.5 4-4L10.5 8h2l-1.5 5.8c-.8 3-3 5.7-6 5.7a4 4 0 0 1-3-1.3"/></svg>';
        if (!c.svgCode_insertemoji) c.svgCode_insertemoji = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><path d="M8 15c1 1.5 2.5 2 4 2s3-.5 4-2"/><circle cx="9" cy="10" r="0.5" fill="currentColor" stroke="none"/><circle cx="15" cy="10" r="0.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_formatblock) c.svgCode_formatblock = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="6" y1="5" x2="18" y2="5"/><line x1="12" y1="5" x2="12" y2="19"/><line x1="9" y1="19" x2="15" y2="19"/></svg>';
        if (!c.svgCode_fontname) c.svgCode_fontname = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="5 19 9.5 5 14 19"/><line x1="7" y1="14" x2="12" y2="14"/><circle cx="19" cy="9.5" r="1" fill="currentColor" stroke="none"/><circle cx="19" cy="13.5" r="1" fill="currentColor" stroke="none"/><circle cx="19" cy="17.5" r="1" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_fontsize) c.svgCode_fontsize = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="9" x2="9" y2="9"/><line x1="6" y1="9" x2="6" y2="19"/><line x1="13" y1="5" x2="21" y2="5"/><line x1="17" y1="5" x2="17" y2="19"/></svg>';
        if (!c.svgCode_lineheight) c.svgCode_lineheight = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="11" y1="6" x2="21" y2="6"/><line x1="11" y1="12" x2="21" y2="12"/><line x1="11" y1="18" x2="21" y2="18"/><polyline points="6 4 3 7 6 7"/><line x1="3" y1="7" x2="3" y2="17"/><polyline points="6 20 3 17 6 17"/></svg>';
        if (!c.svgCode_forecolor) c.svgCode_forecolor = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><path d="M7 18L12 5l5 13"/><line x1="8.8" y1="13.5" x2="15.2" y2="13.5"/><rect x="4" y="19" width="16" height="2.75" rx="1.375" fill="#ef4444" stroke="none"/></svg>';
        if (!c.svgCode_backcolor) c.svgCode_backcolor = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.7" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="14.75" width="16" height="5.5" rx="1.75" fill="#facc15" stroke="none"/><path d="M7 18L12 5l5 13"/><line x1="8.8" y1="13.5" x2="15.2" y2="13.5"/></svg>';
        if (!c.svgCode_removeformat) c.svgCode_removeformat = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="6" y1="5" x2="18" y2="5"/><path d="M10 5l-3 14"/><line x1="3" y1="3" x2="21" y2="21"/></svg>';
        if (!c.svgCode_toggleborder) c.svgCode_toggleborder = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="14" height="14" rx="1"/><rect x="9" y="9" width="6" height="6" rx="0.5"/></svg>';
        if (!c.svgCode_code) c.svgCode_code = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 6 2 12 8 18"/><polyline points="16 6 22 12 16 18"/></svg>';
        if (!c.svgCode_preview) c.svgCode_preview = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-7.5 11-7.5S23 12 23 12s-4 7.5-11 7.5S1 12 1 12z"/><circle cx="12" cy="12" r="3"/></svg>';
        if (!c.svgCode_print) c.svgCode_print = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 6 3 18 3 18 9"/><path d="M6 17H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2"/><rect x="6" y="14" width="12" height="7"/><circle cx="18" cy="12" r="0.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_fullscreen) c.svgCode_fullscreen = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="15 3 21 3 21 9"/><polyline points="9 21 3 21 3 15"/><polyline points="21 15 21 21 15 21"/><polyline points="3 9 3 3 9 3"/></svg>';
        if (!c.svgCode_undo) c.svgCode_undo = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="2 8 2 14 8 14"/><path d="M4.5 11.5A8.5 8.5 0 1 1 5 17"/></svg>';
        if (!c.svgCode_redo) c.svgCode_redo = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="22 8 22 14 16 14"/><path d="M19.5 11.5A8.5 8.5 0 1 0 19 17"/></svg>';
        if (!c.svgCode_find) c.svgCode_find = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="10" cy="10" r="6"/><line x1="21" y1="21" x2="14.5" y2="14.5"/></svg>';
        if (!c.svgCode_paragraphop) c.svgCode_paragraphop = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4a5 5 0 0 0 0 10"/><line x1="12" y1="4" x2="12" y2="20"/><line x1="16" y1="4" x2="16" y2="20"/><line x1="10" y1="4" x2="18" y2="4"/></svg>';
        if (!c.svgCode_pmore) c.svgCode_pmore = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="7" x2="19" y2="7"/><line x1="5" y1="12" x2="19" y2="12"/><line x1="5" y1="17" x2="13" y2="17"/><polyline points="17 15 21 18 17 21"/></svg>';
        if (!c.svgCode_ltr) c.svgCode_ltr = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4a4 4 0 0 0 0 8"/><line x1="12" y1="4" x2="12" y2="19"/><line x1="16" y1="4" x2="16" y2="19"/><line x1="10" y1="4" x2="18" y2="4"/><polyline points="4 15 8 18 4 21"/><line x1="8" y1="18" x2="20" y2="18"/></svg>';
        if (!c.svgCode_rtl) c.svgCode_rtl = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4a4 4 0 0 0 0 8"/><line x1="12" y1="4" x2="12" y2="19"/><line x1="16" y1="4" x2="16" y2="19"/><line x1="10" y1="4" x2="18" y2="4"/><polyline points="20 15 16 18 20 21"/><line x1="4" y1="18" x2="16" y2="18"/></svg>';
        if (!c.svgCode_selectall) c.svgCode_selectall = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="5" y="5" width="14" height="14" rx="1" stroke-dasharray="3 2"/><rect x="8" y="8" width="8" height="8" rx="0.5"/></svg>';

        // New feature icons
        if (!c.svgCode_insertpagebreak) c.svgCode_insertpagebreak = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 2h12a1 1 0 0 1 1 1v5H5V3a1 1 0 0 1 1-1z"/><path d="M6 22h12a1 1 0 0 0 1-1v-5H5v5a1 1 0 0 0 1 1z"/><line x1="3" y1="12" x2="5" y2="12"/><line x1="7" y1="12" x2="9" y2="12"/><line x1="11" y1="12" x2="13" y2="12"/><line x1="15" y1="12" x2="17" y2="12"/><line x1="19" y1="12" x2="21" y2="12"/></svg>';
        if (!c.svgCode_casechange) c.svgCode_casechange = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="4 19 8 8 12 19"/><line x1="5.5" y1="15" x2="10.5" y2="15"/><circle cx="17" cy="15" r="3"/><line x1="20" y1="11" x2="20" y2="19"/></svg>';
        if (!c.svgCode_changecase) c.svgCode_changecase = c.svgCode_casechange;
        if (!c.svgCode_formatpainter) c.svgCode_formatpainter = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="2" width="14" height="5" rx="1"/><path d="M18 4h2v5H9v10a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-6"/></svg>';
        if (!c.svgCode_insertbookmark) c.svgCode_insertbookmark = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v17l-6-3-6 3V4z"/></svg>';
        if (!c.svgCode_inserttodolist) c.svgCode_inserttodolist = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="13" y1="8" x2="21" y2="8"/><line x1="13" y1="16" x2="21" y2="16"/><polyline points="3 8 5.5 10.5 10 5.5"/><polyline points="3 16 5.5 18.5 10 13.5"/></svg>';
        if (!c.svgCode_inserttoc) c.svgCode_inserttoc = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="7" x2="17" y2="7"/><line x1="3" y1="12" x2="17" y2="12"/><line x1="3" y1="17" x2="17" y2="17"/><circle cx="20" cy="7" r="1" fill="currentColor" stroke="none"/><circle cx="20" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="20" cy="17" r="1" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_insertmergefield) c.svgCode_insertmergefield = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M8 4l-4 4 4 4"/><path d="M16 4l4 4-4 4"/><line x1="4" y1="8" x2="20" y2="8"/><line x1="7" y1="16" x2="17" y2="16"/><line x1="7" y1="20" x2="17" y2="20"/></svg>';
        if (!c.svgCode_insertfootnote) c.svgCode_insertfootnote = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><line x1="7" y1="8" x2="11" y2="8"/><line x1="7" y1="12" x2="17" y2="12"/><line x1="7" y1="16" x2="17" y2="16"/></svg>';
        if (!c.svgCode_spellcheck) c.svgCode_spellcheck = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="2 19 6 8 10 19"/><line x1="3.5" y1="15" x2="8.5" y2="15"/><line x1="15" y1="8" x2="21" y2="8"/><line x1="15" y1="12" x2="21" y2="12"/><line x1="17" y1="16" x2="21" y2="16"/><polyline points="10 15 13 18 18 13"/></svg>';
        if (!c.svgCode_importword) c.svgCode_importword = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><polyline points="8 13 10 18 12 13 14 18 16 13"/></svg>';
        if (!c.svgCode_exportpdf) c.svgCode_exportpdf = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><text x="12" y="17" font-size="7" font-family="sans-serif" fill="currentColor" stroke="none" text-anchor="middle" font-weight="bold">PDF</text></svg>';
        if (!c.svgCode_exportword) c.svgCode_exportword = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><polyline points="8 13 10 18 12 13 14 18 16 13"/></svg>';
        if (!c.svgCode_insertmention) c.svgCode_insertmention = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="4"/><path d="M16 8v5a2.5 2.5 0 0 0 5 0V12a9 9 0 1 0-3.6 7.2"/></svg>';
        if (!c.svgCode_insertcomment) c.svgCode_insertcomment = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 4v12a2 2 0 0 1-2 2H6l-4 4V4a2 2 0 0 1 2-2h15a2 2 0 0 1 2 2z"/><line x1="7" y1="7" x2="17" y2="7"/><line x1="7" y1="11" x2="17" y2="11"/><line x1="7" y1="15" x2="13" y2="15"/></svg>';
        if (!c.svgCode_trackchanges) c.svgCode_trackchanges = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="9"/><polyline points="9 12 11 14.5 15.5 9.5"/></svg>';
        if (!c.svgCode_revisionhistory) c.svgCode_revisionhistory = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="1 4 1 10 7 10"/><path d="M3.5 14a9 9 0 1 0 1.3-5.3L1 10"/><polyline points="12 7 12 12 16 14"/></svg>';
        if (!c.svgCode_autoformatting) c.svgCode_autoformatting = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="5" x2="13" y2="5"/><line x1="3" y1="12" x2="9" y2="12"/><line x1="3" y1="19" x2="7" y2="19"/><line x1="17" y1="3" x2="17" y2="9"/><line x1="14" y1="6" x2="20" y2="6"/><line x1="12" y1="17" x2="21" y2="17"/><line x1="12" y1="14" x2="21" y2="14"/></svg>';
        if (!c.svgCode_multilevellist) c.svgCode_multilevellist = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="11" y1="6" x2="21" y2="6"/><line x1="11" y1="12" x2="21" y2="12"/><line x1="11" y1="18" x2="21" y2="18"/><circle cx="4" cy="6" r="1" fill="currentColor" stroke="none"/><circle cx="7" cy="12" r="1" fill="currentColor" stroke="none"/><circle cx="4" cy="18" r="1" fill="currentColor" stroke="none"/></svg>';

        // Clipboard & editing icons
        if (!c.svgCode_cut) c.svgCode_cut = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="6" r="3"/><circle cx="6" cy="18" r="3"/><line x1="20" y1="4" x2="8.6" y2="15.4"/><line x1="14.5" y1="9.5" x2="20" y2="4"/><line x1="8.6" y1="8.6" x2="12" y2="12"/></svg>';
        if (!c.svgCode_copy) c.svgCode_copy = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="8" y="6" width="12" height="16" rx="2"/><path d="M16 4h-8a2 2 0 0 0-2 2v12"/></svg>';
        if (!c.svgCode_paste) c.svgCode_paste = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>';
        if (!c.svgCode_delete) c.svgCode_delete = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="3 6 5 6 21 6"/><path d="M19 6l-1 14a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2L5 6"/><path d="M9 6V4a1 1 0 0 1 1-1h4a1 1 0 0 1 1 1v2"/><line x1="10" y1="10" x2="10" y2="17"/><line x1="14" y1="10" x2="14" y2="17"/></svg>';
        if (!c.svgCode_save) c.svgCode_save = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M19 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h11l5 5v11a2 2 0 0 1-2 2z"/><polyline points="17 21 17 13 7 13 7 21"/><polyline points="7 3 7 8 15 8"/></svg>';
        if (!c.svgCode_new) c.svgCode_new = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="12" y1="13" x2="12" y2="19"/><line x1="9" y1="16" x2="15" y2="16"/></svg>';

        // Paste mode icons
        if (!c.svgCode_ribbonpaste) c.svgCode_ribbonpaste = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>';
        if (!c.svgCode_pastetext) c.svgCode_pastetext = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3"/><rect x="8" y="2" width="8" height="4" rx="1"/><line x1="8" y1="12" x2="16" y2="12"/><line x1="8" y1="16" x2="12" y2="16"/></svg>';
        if (!c.svgCode_pasteword) c.svgCode_pasteword = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16 4h3a1 1 0 0 1 1 1v15a1 1 0 0 1-1 1H5a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h3"/><rect x="8" y="2" width="8" height="4" rx="1"/><polyline points="8 13 10 18 12 13 14 18 16 13"/></svg>';

        // Table operation icons (outlined style)
        if (!c.svgCode_tablecellmerge) c.svgCode_tablecellmerge = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="9" y1="9" x2="9" y2="15"/><path d="M9,12L15,12" stroke-width="0" fill="currentColor" opacity="0.3"/><path d="M10,11h4v2h-4z" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_tablecellsplitver) c.svgCode_tablecellsplitver = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>';
        if (!c.svgCode_tablecellsplithor) c.svgCode_tablecellsplithor = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/></svg>';
        if (!c.svgCode_tablerowinsertabove) c.svgCode_tablerowinsertabove = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="13" width="18" height="8" rx="1"/><line x1="9" y1="13" x2="9" y2="21"/><line x1="15" y1="13" x2="15" y2="21"/><line x1="12" y1="3" x2="12" y2="10"/><line x1="8.5" y1="6.5" x2="12" y2="3"/><line x1="15.5" y1="6.5" x2="12" y2="3"/></svg>';
        if (!c.svgCode_tablerowinsertbelow) c.svgCode_tablerowinsertbelow = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="8" rx="1"/><line x1="9" y1="3" x2="9" y2="11"/><line x1="15" y1="3" x2="15" y2="11"/><line x1="12" y1="14" x2="12" y2="21"/><line x1="8.5" y1="17.5" x2="12" y2="21"/><line x1="15.5" y1="17.5" x2="12" y2="21"/></svg>';
        if (!c.svgCode_tablerowdelete) c.svgCode_tablerowdelete = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="8" rx="1"/><line x1="9" y1="3" x2="9" y2="11"/><line x1="15" y1="3" x2="15" y2="11"/><rect x="3" y="15" width="18" height="6" rx="1"/><line x1="9" y1="18" x2="15" y2="18" stroke="red" stroke-width="2"/></svg>';
        if (!c.svgCode_tablecolumninsertleft) c.svgCode_tablecolumninsertleft = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="13" y="3" width="8" height="18" rx="1"/><line x1="13" y1="9" x2="21" y2="9"/><line x1="13" y1="15" x2="21" y2="15"/><line x1="3" y1="12" x2="10" y2="12"/><line x1="6.5" y1="8.5" x2="3" y2="12"/><line x1="6.5" y1="15.5" x2="3" y2="12"/></svg>';
        if (!c.svgCode_tablecolumninsertright) c.svgCode_tablecolumninsertright = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="8" height="18" rx="1"/><line x1="3" y1="9" x2="11" y2="9"/><line x1="3" y1="15" x2="11" y2="15"/><line x1="14" y1="12" x2="21" y2="12"/><line x1="17.5" y1="8.5" x2="21" y2="12"/><line x1="17.5" y1="15.5" x2="21" y2="12"/></svg>';
        if (!c.svgCode_tablecolumndelete) c.svgCode_tablecolumndelete = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="6" height="18" rx="1"/><line x1="3" y1="9" x2="9" y2="9"/><line x1="3" y1="15" x2="9" y2="15"/><rect x="15" y="3" width="6" height="18" rx="1"/><line x1="15" y1="9" x2="21" y2="9"/><line x1="15" y1="15" x2="21" y2="15"/><line x1="11" y1="10" x2="13" y2="14" stroke="red" stroke-width="1.5"/><line x1="13" y1="10" x2="11" y2="14" stroke="red" stroke-width="1.5"/></svg>';
        if (!c.svgCode_tabledelete) c.svgCode_tabledelete = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/><line x1="7" y1="7" x2="17" y2="17" stroke="red" stroke-width="2"/><line x1="17" y1="7" x2="7" y2="17" stroke="red" stroke-width="2"/></svg>';
        if (!c.svgCode_tableheader) c.svgCode_tableheader = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="9" y1="9" x2="9" y2="21"/><line x1="15" y1="9" x2="15" y2="21"/><rect x="3.5" y="3.5" width="17" height="5.5" rx="0" fill="currentColor" opacity="0.15" stroke="none"/></svg>';
        if (!c.svgCode_tablecell) c.svgCode_tablecell = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="3" y1="12" x2="21" y2="12"/></svg>';
        if (!c.svgCode_menu_tablecell) c.svgCode_menu_tablecell = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="12" y1="3" x2="12" y2="21"/><line x1="3" y1="12" x2="21" y2="12"/></svg>';
        if (!c.svgCode_tablerow) c.svgCode_tablerow = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/></svg>';
        if (!c.svgCode_menu_tablerow) c.svgCode_menu_tablerow = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/></svg>';
        if (!c.svgCode_tablecolumn) c.svgCode_tablecolumn = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>';
        if (!c.svgCode_menu_tablecolumn) c.svgCode_menu_tablecolumn = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/></svg>';
        if (!c.svgCode_table) c.svgCode_table = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="1"/><line x1="9" y1="3" x2="9" y2="21"/><line x1="15" y1="3" x2="15" y2="21"/><line x1="3" y1="9" x2="21" y2="9"/><line x1="3" y1="15" x2="21" y2="15"/></svg>';
        if (!c.svgCode_menu_table) c.svgCode_menu_table = c.svgCode_table;
        if (!c.svgCode_controlsizeauto) c.svgCode_controlsizeauto = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="18" height="12" rx="1"/><path d="M7,10L5,12l2,2" fill="none"/><path d="M17,10l2,2-2,2" fill="none"/></svg>';
        if (!c.svgCode_controlsize100) c.svgCode_controlsize100 = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="18" height="12" rx="1"/><text x="12" y="15" text-anchor="middle" font-size="7" fill="currentColor" stroke="none" font-family="Arial">100</text></svg>';
        if (!c.svgCode_controlsize75) c.svgCode_controlsize75 = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="14" height="12" rx="1"/><text x="10" y="15" text-anchor="middle" font-size="7" fill="currentColor" stroke="none" font-family="Arial">75</text></svg>';
        if (!c.svgCode_controlsize50) c.svgCode_controlsize50 = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="6" width="10" height="12" rx="1"/><text x="8" y="15" text-anchor="middle" font-size="7" fill="currentColor" stroke="none" font-family="Arial">50</text></svg>';

        // Missing command icons (outlined style)
        if (!c.svgCode_insertcode) c.svgCode_insertcode = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><polyline points="8 7 3 12 8 17"/><polyline points="16 7 21 12 16 17"/><line x1="14" y1="5" x2="10" y2="19"/></svg>';
        if (!c.svgCode_html2pdf) c.svgCode_html2pdf = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14,2H6A2,2,0,0,0,4,4V20a2,2,0,0,0,2,2H18a2,2,0,0,0,2-2V8Z"/><polyline points="14,2 14,8 20,8"/><text x="12" y="17" text-anchor="middle" font-size="6.5" fill="currentColor" stroke="none" font-weight="bold" font-family="Arial">PDF</text></svg>';
        if (!c.svgCode_pasteauto) c.svgCode_pasteauto = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M16,4h3a1,1,0,0,1,1,1V20a1,1,0,0,1-1,1H5a1,1,0,0,1-1-1V5A1,1,0,0,1,5,4H8"/><rect x="8" y="2" width="8" height="4" rx="1"/></svg>';
        if (!c.svgCode_imageeditor) c.svgCode_imageeditor = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M11,4H4A2,2,0,0,0,2,6V20a2,2,0,0,0,2,2H18a2,2,0,0,0,2-2V13"/><path d="M18.5,2.5a2.121,2.121,0,0,1,3,3L12,15,8,16l1-4Z"/></svg>';
        if (!c.svgCode_justifymenu) c.svgCode_justifymenu = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="10" x2="15" y2="10"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="3" y1="18" x2="15" y2="18"/></svg>';
        if (!c.svgCode_insertlinemenu) c.svgCode_insertlinemenu = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/><line x1="3" y1="18" x2="21" y2="18"/><polyline points="11,13 15,15 11,17" fill="none"/></svg>';
        if (!c.svgCode_ribbontable) c.svgCode_ribbontable = c.svgCode_table;
        if (!c.svgCode_pmore) c.svgCode_pmore = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="4" y1="7" x2="20" y2="7"/><line x1="4" y1="12" x2="14" y2="12"/><line x1="4" y1="17" x2="14" y2="17"/><polyline points="17,10 21,12 17,14" fill="none"/></svg>';

        // Dialog/upload icons (outlined style)
        if (!c.svgCode_imageupload) c.svgCode_imageupload = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="18" height="18" rx="2"/><circle cx="8.5" cy="8.5" r="1.5"/><polyline points="21,15 16,10 5,21"/><line x1="17" y1="3" x2="17" y2="9"/><line x1="14" y1="6" x2="20" y2="6"/></svg>';
        if (!c.svgCode_documentupload) c.svgCode_documentupload = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14,2H6A2,2,0,0,0,4,4V20a2,2,0,0,0,2,2H18a2,2,0,0,0,2-2V8Z"/><polyline points="14,2 14,8 20,8"/><line x1="12" y1="18" x2="12" y2="12"/><polyline points="9,15 12,12 15,15"/></svg>';
        if (!c.svgCode_DialogClose) c.svgCode_DialogClose = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"><line x1="18" y1="6" x2="6" y2="18"/><line x1="6" y1="6" x2="18" y2="18"/></svg>';
        if (!c.svgCode_default) c.svgCode_default = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="4" width="16" height="16" rx="2"/></svg>';

        // Paragraph & format icons
        if (!c.svgCode_paragraphs) c.svgCode_paragraphs = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="5" y1="4" x2="19" y2="4"/><line x1="10.5" y1="4" x2="10.5" y2="19"/><line x1="13.5" y1="4" x2="13.5" y2="19"/><line x1="5" y1="4" x2="5" y2="7"/></svg>';
        if (!c.svgCode_paragraphstyle) c.svgCode_paragraphstyle = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 4h13.5"/><line x1="8" y1="4" x2="8" y2="19"/><path d="M12.5 9h9"/><line x1="17" y1="9" x2="17" y2="19"/></svg>';
        if (!c.svgCode_inlinestyle) c.svgCode_inlinestyle = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M4 20h16"/><path d="M14.5 4l1.5 1.5L9 12.5 7 14l1.5-2L15.5 5"/><path d="M15 3.5a1.5 1.5 0 0 1 2.1 0l.4.4a1.5 1.5 0 0 1 0 2.1l-1 1-2.5-2.5 1-1z"/><path d="M5 16h13"/></svg>';
        if (!c.svgCode_styles) c.svgCode_styles = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M2.5 4h13.5"/><line x1="8" y1="4" x2="8" y2="19"/><path d="M12.5 9h9"/><line x1="17" y1="9" x2="17" y2="19"/></svg>';
        if (!c.svgCode_menu_paragraphop) c.svgCode_menu_paragraphop = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="17" x2="21" y2="17"/><polyline points="18,19 21,22 24,19"/></svg>';
        if (!c.svgCode_toggle_paragraphop) c.svgCode_toggle_paragraphop = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="12" x2="15" y2="12"/><line x1="3" y1="17" x2="9" y2="17"/></svg>';

        // Fullscreen, toggle, plus
        if (!c.svgCode_fullscreenenter) c.svgCode_fullscreenenter = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="5,9 5,5 9,5"/><polyline points="15,5 19,5 19,9"/><polyline points="19,15 19,19 15,19"/><polyline points="9,19 5,19 5,15"/></svg>';
        if (!c.svgCode_fullscreenexit) c.svgCode_fullscreenexit = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9,5 9,9 5,9"/><polyline points="19,9 15,9 15,5"/><polyline points="15,19 15,15 19,15"/><polyline points="5,15 9,15 9,19"/></svg>';
        if (!c.svgCode_togglemore) c.svgCode_togglemore = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="6" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="12" r="1.5" fill="currentColor" stroke="none"/><circle cx="18" cy="12" r="1.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_plusbtn) c.svgCode_plusbtn = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="12" y1="5" x2="12" y2="19"/><line x1="5" y1="12" x2="19" y2="12"/></svg>';

        // Office toolbar specific icons
        if (!c.svgCode_cleancode) c.svgCode_cleancode = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="8,6 2,12 8,18"/><polyline points="16,6 22,12 16,18"/><line x1="14" y1="3" x2="10" y2="21"/></svg>';
        if (!c.svgCode_justifymenu) c.svgCode_justifymenu = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="7" x2="21" y2="7"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="17" x2="21" y2="17"/></svg>';
        if (!c.svgCode_insertlinemenu) c.svgCode_insertlinemenu = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><line x1="3" y1="6" x2="21" y2="6"/><line x1="3" y1="12" x2="21" y2="12"/><line x1="3" y1="18" x2="21" y2="18"/></svg>';
        if (!c.svgCode_ribbontable) c.svgCode_ribbontable = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="5" width="18" height="14" rx="1.5"/><line x1="3" y1="9.5" x2="21" y2="9.5"/><line x1="3" y1="14" x2="21" y2="14"/><line x1="9" y1="5" x2="9" y2="19"/><line x1="15" y1="5" x2="15" y2="19"/></svg>';
        if (!c.svgCode_help) c.svgCode_help = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="12" r="10"/><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3"/><circle cx="12" cy="17" r="0.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_insertanchor) c.svgCode_insertanchor = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><circle cx="12" cy="5.5" r="2.5"/><line x1="12" y1="8" x2="12" y2="21"/><path d="M5 12H3v2c0 3.5 4 6.5 9 6.5s9-3 9-6.5v-2h-2"/><line x1="3" y1="14" x2="7" y2="11"/><line x1="21" y1="14" x2="17" y2="11"/></svg>';
        if (!c.svgCode_insertdate) c.svgCode_insertdate = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="4" width="18" height="18" rx="2"/><line x1="16" y1="2" x2="16" y2="6"/><line x1="8" y1="2" x2="8" y2="6"/><line x1="3" y1="10" x2="21" y2="10"/><circle cx="8" cy="14" r="0.5" fill="currentColor" stroke="none"/><circle cx="12" cy="14" r="0.5" fill="currentColor" stroke="none"/><circle cx="16" cy="14" r="0.5" fill="currentColor" stroke="none"/><circle cx="8" cy="18" r="0.5" fill="currentColor" stroke="none"/><circle cx="12" cy="18" r="0.5" fill="currentColor" stroke="none"/></svg>';
        if (!c.svgCode_insertdocument) c.svgCode_insertdocument = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14,2H6A2,2,0,0,0,4,4V20a2,2,0,0,0,2,2H18a2,2,0,0,0,2-2V8Z"/><polyline points="14,2 14,8 20,8"/><line x1="8" y1="13" x2="16" y2="13"/><line x1="8" y1="17" x2="16" y2="17"/><line x1="8" y1="9" x2="10" y2="9"/></svg>';
        if (!c.svgCode_underlinemenu) c.svgCode_underlinemenu = '<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M6 4v6a6 6 0 0 0 12 0V4"/><line x1="4" y1="21" x2="20" y2="21"/></svg>';

        // Float toolbar icons (context-sensitive toolbars for tables, images, links)
        if (!c.svgCode_linkstyle) c.svgCode_linkstyle = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path fill="#f6f6f6" d="M.572 9.992l6.414-6.415 1.5 1.5 4.5-4.5 2.414 2.414-4.5 4.5 1.5 1.5-6.415 6.415-5.413-5.414z"/><path fill="#424242" d="M6 14l-4-4.008 3-2.992 4.001 3.993-3.001 3.007zm5-5.008l-4-3.992-1 .991 3.986 4.009 1.014-1.008zm3-6.001l-1.014-.991-3.984 3.991.998 1 4-4z" id="iconBg"/></svg>';
        if (!c.svgCode_tableheader) c.svgCode_tableheader = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path d="M14,5h-3V4h-1v1H7V4H6v1H3V4H2v11h13V4h-1V5z M6,14H3v-2h3V14z M6,11H3V9h3V11z M6,8H3V6h3V8z M10,14H7v-2h3V14z M10,11H7V9h3V11z M10,8H7V6h3V8z M14,14h-3v-2h3V14z M14,11h-3V9h3V11z M14,8h-3V6h3V8z M2,1h13v2H2V1z"/></svg>';
        if (!c.svgCode_menu_tablecell) c.svgCode_menu_tablecell = '<svg viewBox="-1 -1 18 18" fill="#5F6368"><path d="M2,2v11h12V2H2z M3,3h3v3H3V3z M3,12V7h3v5H3z M7,6V3h6v3H7z"/><path fill="#F0EFF1" d="M13,6H7V3h6V6z M6,3H3v3h3V3z M6,7H3v5h3V7z"/></svg>';
        if (!c.svgCode_menu_tablerow) c.svgCode_menu_tablerow = '<svg viewBox="-2 -2 20 20"><path fill="#F0EFF1" d="M7,13h3v-2H7V13z M7,10h3V8H7V10z M7,7h3V5H7V7z M11,13h3v-2h-3V13z M11,10h3V8h-3V10z M11,5v2h3V5H11z"/><path fill="#666666" d="M11,8h3v2h-3V8z M7,10h3V8H7V10z M3,8v2h3V8H3z"/><path fill="#5F6368" d="M2,2v12h13V2H2z M6,13H3v-2h3V13z M6,10H3V8h3V10z M6,7H3V5h3V7z M10,13H7v-2h3V13z M10,10H7V8h3V10z M10,7H7V5h3V7z M14,13h-3v-2h3V13z M14,10h-3V8h3V10z M14,7h-3V5h3V7z"/></svg>';
        if (!c.svgCode_menu_tablecolumn) c.svgCode_menu_tablecolumn = '<svg viewBox="-2 -2 20 20"><g><path fill="#F0EFF1" d="M7,13h3v-2H7V13z M7,10h3V8H7V10z M7,7h3V5H7V7z M11,13h3v-2h-3V13z M11,10h3V8h-3V10z M11,5v2h3V5H11z"/><path fill="#666666" d="M7,11h3v2H7V11z M7,10h3V8H7V10z M7,5v2h3V5H7z"/></g><g><path fill="#5F6368" d="M2,2v12h13V2H2z M6,13H3v-2h3V13z M6,10H3V8h3V10z M6,7H3V5h3V7z M10,13H7v-2h3V13z M10,10H7V8h3V10z M10,7H7V5h3V7z M14,13h-3v-2h3V13z M14,10h-3V8h3V10z M14,7h-3V5h3V7z"/></g></svg>';
        if (!c.svgCode_menu_table) c.svgCode_menu_table = c.svgCode_inserttable;
        if (!c.svgCode_menu_controlsize) c.svgCode_controlsize = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path fill="#f6f6f6" d="M16 7h-2v7h-7v2h-7v-7h2v-7h7v-2h7v7z"/><path fill="#5F6368" d="M13 3v10h-10v-10h10zm-1 8l-1.5-1.549-2 1.549-2.5-3.126-2 2.21v1.916h8v-1zm0-7h-8v4.084l2-2.21 2.5 3.126 2-1 1.5 1v-5zm-2 1h-2v2h2v-2zm5 1l-.019-5h-4.981v1h4v4h1zm-14 4l.019 5h4.981v-1h-4v-4h-1z"/><path fill="#F0EFF1" d="M12 12h-8v-1.916l2-2.21 2.5 3.126 2-1.549 1.5 1.549v1zm0-8v5l-1.5-1-2 1-2.5-3.126-2 2.21v-4.084h8zm-2 1h-2v2h2v-2z" id="iconFg"/></svg>';
        if (!c.svgCode_menu_controlsize) c.svgCode_menu_controlsize = c.svgCode_controlsize;
        if (!c.svgCode_imagecaption) c.svgCode_imagecaption = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path fill="#5F6368" d="M3,1v7l1-1V2h8v5l-1.5-1L13,7.7V1H3z M4,10H3v5h10v-5H4z M4,11h5v1H4V11z M12,14H4v-1h8V14z"/><circle fill="#C27D1A" cx="9" cy="4" r="1"/><path fill="#1BA1E2" d="M13,10H3V8l3-3l2.5,2l2-1L13,7.7V10z"/></svg>';
        if (!c.svgCode_controlalt) c.svgCode_controlalt = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path fill="#f6f6f6" d="M16,6v9H2V9.717l-1,1.1V0H2.392L8.857,6Z"/><path fill="#f0eff1" d="M6.843,8l.426.965L4.261,10.332,4,9.744V13H14V8ZM12,11H6V10h6Z"/><path fill="#424242" d="M12,11H6V10h6ZM9.935,7H6.4l.441,1H14v5H4V9.744L3.336,8.249,3,8.619V14H15V7Z"/><path fill="#00539c" d="M4.766,9,3.629,6.442,2,8.231V1L7.387,6H4.869L5.955,8.463Z"/></svg>';
        if (!c.svgCode_controlinsertlink) c.svgCode_controlinsertlink = c.svgCode_insertlink;
        if (!c.svgCode_controleditlink) c.svgCode_controleditlink = '<svg viewBox="-2 -2 20 20"><path fill="#f6f6f6" d="M13.313 7.235l-.417-.146c-.024-.104-.066-.2-.098-.301l2.453-2.453a2.55 2.55 0 0 0 .748-1.81c0-.684-.266-1.327-.749-1.81C14.796.261 14.136 0 13.439 0s-1.356.261-1.811.715L8.343 4H4C1.794 4 0 5.794 0 8c0 1.69 1.08 3.203 2.688 3.766l.417.146A4.006 4.006 0 0 0 7 15h5c2.206 0 4-1.794 4-4a4 4 0 0 0-2.687-3.765z"/><path fill="#424242" d="M6.041 10.797l3.413-.665.274-.274a2 2 0 0 0 1.13-1.13l1.104-1.104c.016.125.038.247.038.376 0 1.654-1.346 3-3 3H6c0-.072.027-.135.041-.203zM2 8c0-1.103.897-2 2-2h2.343l1-1H4C2.346 5 1 6.346 1 8c0 1.309.847 2.412 2.018 2.821.016-.345.079-.676.177-.993A2.001 2.001 0 0 1 2 8zm10.982.179a3.967 3.967 0 0 1-.177.993A2.002 2.002 0 0 1 14 11c0 1.102-.898 2-2 2H7c-1.103 0-2-.898-2-2 0-.237.049-.462.125-.673l.352-1.897A2.99 2.99 0 0 0 4 11c0 1.654 1.346 3 3 3h5c1.654 0 3-1.346 3-3a2.993 2.993 0 0 0-2.018-2.821z"/><path fill="#00539c" d="M14.543 1.422c-.563-.563-1.645-.563-2.207 0l-5.601 5.6L6 9.965l2.943-.736 5.601-5.6a1.558 1.558 0 0 0-.001-2.207zm-.707 1.5L8.431 8.326l-1.057.264.265-1.057 5.404-5.404c.188-.188.605-.188.793 0a.558.558 0 0 1 0 .793z"/></svg>';
        if (!c.svgCode_controlopenlink) c.svgCode_controlopenlink = '<svg viewBox="-2 -2 20 20"><path d="M1.5 13A1.5 1.5 0 003 14.5h8a1.5 1.5 0 001.5-1.5V9a.5.5 0 00-1 0v4a.5.5 0 01-.5.5H3a.5.5 0 01-.5-.5V5a.5.5 0 01.5-.5h4a.5.5 0 000-1H3A1.5 1.5 0 001.5 5v8zm7-11a.5.5 0 01.5-.5h5a.5.5 0 01.5.5v5a.5.5 0 01-1 0V2.5H9a.5.5 0 01-.5-.5z" clip-rule="evenodd"/> <path d="M14.354 1.646a.5.5 0 010 .708l-8 8a.5.5 0 01-.708-.708l8-8a.5.5 0 01.708 0z" clip-rule="evenodd"/></svg>';
        if (!c.svgCode_controlunlink) c.svgCode_controlunlink = c.svgCode_unlink;
        if (!c.svgCode_menu_controljustify) c.svgCode_menu_controljustify = c.svgCode_justifyleft;
        if (!c.svgCode_imagestyle) c.svgCode_imagestyle = '<svg viewBox="-2 -2 20 20" fill="#5F6368"><path fill="#f6f6f6" d="M.572 9.992l6.414-6.415 1.5 1.5 4.5-4.5 2.414 2.414-4.5 4.5 1.5 1.5-6.415 6.415-5.413-5.414z"/><path fill="#424242" d="M6 14l-4-4.008 3-2.992 4.001 3.993-3.001 3.007zm5-5.008l-4-3.992-1 .991 3.986 4.009 1.014-1.008zm3-6.001l-1.014-.991-3.984 3.991.998 1 4-4z"/></svg>';

        // Float toolbar tooltip labels
        if (!c.text_tableheader) c.text_tableheader = "Table Header";
        if (!c.text_tablecell) c.text_tablecell = "Cell";
        if (!c.text_menu_tablecell) c.text_menu_tablecell = "Cell";
        if (!c.text_tablerow) c.text_tablerow = "Row";
        if (!c.text_menu_tablerow) c.text_menu_tablerow = "Row";
        if (!c.text_tablecolumn) c.text_tablecolumn = "Column";
        if (!c.text_menu_tablecolumn) c.text_menu_tablecolumn = "Column";
        if (!c.text_table) c.text_table = "Table";
        if (!c.text_menu_table) c.text_menu_table = "Table";
        if (!c.text_tablecellmerge) c.text_tablecellmerge = "Merge Cells";
        if (!c.text_tablecellsplitver) c.text_tablecellsplitver = "Split Cell Vertically";
        if (!c.text_tablecellsplithor) c.text_tablecellsplithor = "Split Cell Horizontally";
        if (!c.text_tablerowinsertabove) c.text_tablerowinsertabove = "Insert Row Above";
        if (!c.text_tablerowinsertbelow) c.text_tablerowinsertbelow = "Insert Row Below";
        if (!c.text_tablerowdelete) c.text_tablerowdelete = "Delete Row";
        if (!c.text_tablecolumninsertleft) c.text_tablecolumninsertleft = "Insert Column Left";
        if (!c.text_tablecolumninsertright) c.text_tablecolumninsertright = "Insert Column Right";
        if (!c.text_tablecolumndelete) c.text_tablecolumndelete = "Delete Column";
        if (!c.text_tabledelete) c.text_tabledelete = "Delete Table";
        if (!c.text_tablecellforecolor) c.text_tablecellforecolor = "Cell Text Color";
        if (!c.text_tablecellbackcolor) c.text_tablecellbackcolor = "Cell Background Color";
        if (!c.text_controlsizeauto) c.text_controlsizeauto = "Auto Width";
        if (!c.text_controlsize100) c.text_controlsize100 = "Width 100%";
        if (!c.text_controlsize75) c.text_controlsize75 = "Width 75%";
        if (!c.text_controlsize50) c.text_controlsize50 = "Width 50%";
        if (!c.text_menu_controlsize) c.text_menu_controlsize = "Size";
        if (!c.text_imagecaption) c.text_imagecaption = "Caption";
        if (!c.text_controlalt) c.text_controlalt = "Alt Text";
        if (!c.text_controlinsertlink) c.text_controlinsertlink = "Insert Link";
        if (!c.text_controleditlink) c.text_controleditlink = "Edit Link";
        if (!c.text_controlopenlink) c.text_controlopenlink = "Open Link";
        if (!c.text_controlunlink) c.text_controlunlink = "Remove Link";
        if (!c.text_menu_controljustify) c.text_menu_controljustify = "Align";
        if (!c.text_imagestyle) c.text_imagestyle = "Image Style";
        if (!c.text_imageeditor) c.text_imageeditor = "Edit Image";
        if (!c.text_linkstyle) c.text_linkstyle = "Link Style";

        // More subtoolbar missing icons
        if (!c.svgCode_strike) c.svgCode_strike = c.svgCode_linethrough;
        if (!c.svgCode_ucase) c.svgCode_ucase = '<svg viewBox="0 0 24 24"><path d="M12.1,3h2l-4.2,11H7.7L3.5,3h2l3.3,8.7L12.1,3z M5,16h14v2H5V16z"/></svg>';
        if (!c.svgCode_lcase) c.svgCode_lcase = '<svg viewBox="0 0 24 24"><path d="M13.5,11c0-1.7-1.3-3-3-3s-3,1.3-3,3v3c0,1.7,1.3,3,3,3s3-1.3,3-3V11z M11.5,14c0,0.6-0.4,1-1,1s-1-0.4-1-1v-3c0-0.6,0.4-1,1-1s1,0.4,1,1V14z M17.5,8h-2v9h2V8z"/><path d="M5,19h14v2H5V19z"/></svg>';
        if (!c.svgCode_inserthorizontalrule) c.svgCode_inserthorizontalrule = '<svg viewBox="0 0 24 24"><path d="M3,11h18v2H3V11z M3,5h18v2H3V5z M3,17h18v2H3V17z"/></svg>';
        if (!c.svgCode_newdoc) c.svgCode_newdoc = '<svg viewBox="0 0 24 24"><path d="M14,2H6C4.9,2,4,2.9,4,4v16c0,1.1,0.9,2,2,2h12c1.1,0,2-0.9,2-2V8L14,2z M16,18h-3v3h-2v-3H8v-2h3v-3h2v3h3V18z M13,9V3.5L18.5,9H13z"/></svg>';
        if (!c.svgCode_load) c.svgCode_load = '<svg viewBox="0 0 24 24"><path d="M19,9h-4V3H9v6H5l7,7L19,9z M5,18v2h14v-2H5z"/></svg>';
        if (!c.text_strike) c.text_strike = "Strikethrough";
        if (!c.text_ucase) c.text_ucase = "Uppercase";
        if (!c.text_lcase) c.text_lcase = "Lowercase";
        if (!c.text_inserthorizontalrule) c.text_inserthorizontalrule = "Horizontal Rule";
        if (!c.text_html2pdf) c.text_html2pdf = "Export PDF";
        if (!c.text_newdoc) c.text_newdoc = "New Document";
        if (!c.text_load) c.text_load = "Load";

        // Float paragraph toolbar icons
        if (!c.svgCode_pmoveup) c.svgCode_pmoveup = '<svg viewBox="0 0 24 24"><path d="M7,14l5-5,5,5Z"/></svg>';
        if (!c.svgCode_pmovedown) c.svgCode_pmovedown = '<svg viewBox="0 0 24 24"><path d="M7,10l5,5,5-5Z"/></svg>';
        if (!c.svgCode_pduplicate) c.svgCode_pduplicate = '<svg viewBox="0 0 24 24"><path d="M16,1H4C2.9,1,2,1.9,2,3v14h2V3h12V1z M19,5H8C6.9,5,6,5.9,6,7v14c0,1.1,0.9,2,2,2h11c1.1,0,2-0.9,2-2V7C21,5.9,20.1,5,19,5z M19,21H8V7h11V21z"/></svg>';
        if (!c.svgCode_pdelete) c.svgCode_pdelete = c.svgCode_delete;
        if (!c.text_pmoveup) c.text_pmoveup = "Move Up";
        if (!c.text_pmovedown) c.text_pmovedown = "Move Down";
        if (!c.text_pduplicate) c.text_pduplicate = "Duplicate";
        if (!c.text_pdelete) c.text_pdelete = "Delete";

        if (!c.paragraphItems) {
            c.paragraphItems = "Normal,H1,H2,H3,H4,H5,H6,Pre";
        }

        // Make inserted tables full-width like CKEditor
        if (!c.insertTableTag) {
            c.insertTableTag = '<table style="width:100%;border-collapse:collapse;" border="1" cellpadding="6" cellspacing="0"></table>';
        }
        if (!c.insertCellTag) {
            c.insertCellTag = '<td style="border:1px solid #bfbfbf;min-width:2em;padding:8px;"></td>';
        }

        if (!window.RTE_DefaultConfig.toolbar_minimal) {
            window.RTE_DefaultConfig.toolbar_minimal = "{bold,italic,underline}|{insertlink}|{insertemoji}|{undo,redo}";
        }
        // English tooltip text defaults for new buttons
        if (!c.text_inserttodolist) c.text_inserttodolist = "Todo List";
        if (!c.text_casechange) c.text_casechange = "Change Case";
        if (!c.text_formatpainter) c.text_formatpainter = "Format Painter";
        if (!c.text_insertmergefield) c.text_insertmergefield = "Insert Merge Field";
        if (!c.text_insertfootnote) c.text_insertfootnote = "Insert Footnote";
        if (!c.text_inserttoc) c.text_inserttoc = "Table of Contents";
        if (!c.text_insertpagebreak) c.text_insertpagebreak = "Page Break";
        if (!c.text_importword) c.text_importword = "Import Word";
        if (!c.text_exportword) c.text_exportword = "Export Word";
        if (!c.text_exportpdf) c.text_exportpdf = "Export PDF";
        if (!c.text_insertcomment) c.text_insertcomment = "Insert Comment";
        if (!c.text_trackchanges) c.text_trackchanges = "Track Changes";
        if (!c.text_insertmention) c.text_insertmention = "Mention";
        if (!c.text_revisionhistory) c.text_revisionhistory = "Revision History";
        if (!c.text_multilevellist) c.text_multilevellist = "Multi-Level List";
        if (!c.text_autoformatting) c.text_autoformatting = "Auto Formatting";
        if (!c.text_insertbookmark) c.text_insertbookmark = "Bookmark";
        if (!c.text_spellcheck) c.text_spellcheck = "Spell Check";
        if (!c.text_formatblock) c.text_formatblock = "Paragraph Format";
        if (!c.text_linethrough) c.text_linethrough = "Strikethrough";
        if (!c.text_ltr) c.text_ltr = "Left to Right";
        if (!c.text_rtl) c.text_rtl = "Right to Left";
        if (!c.text_camera) c.text_camera = "Camera";
        if (!c.text_insertimagebycamera) c.text_insertimagebycamera = "Insert Image by Camera";
        if (!c.text_COMMON) c.text_COMMON = "Common";
        if (!c.text_FORMAT) c.text_FORMAT = "Format";
        if (!c.text_PARAGRAPHS) c.text_PARAGRAPHS = "Paragraphs";
        if (!c.text_INSERT) c.text_INSERT = "Insert";
        if (!c.text_REVIEW) c.text_REVIEW = "Review";

        // Dialog / dropdown header labels
        if (!c.text_forecolor) c.text_forecolor = "Text Color";
        if (!c.text_backcolor) c.text_backcolor = "Background Color";
        if (!c.text_colorauto) c.text_colorauto = "Automatic";
        if (!c.text_colormore) c.text_colormore = "More Colors…";
        if (!c.text_insertchars) c.text_insertchars = "Special Characters";
        if (!c.text_paragraphs) c.text_paragraphs = "Paragraphs";
        if (!c.text_fontname) c.text_fontname = "Font Family";
        if (!c.text_fontsize) c.text_fontsize = "Font Size";
        if (!c.text_lineheight) c.text_lineheight = "Line Height";
        if (!c.text_insertlink) c.text_insertlink = "Insert Link";
        if (!c.text_inserttable) c.text_inserttable = "Insert Table";
        if (!c.text_insertimage) c.text_insertimage = "Insert Image";
        if (!c.text_insertgallery) c.text_insertgallery = "Image Gallery";
        if (!c.text_insertvideo) c.text_insertvideo = "Insert Video";
        if (!c.text_inserttemplate) c.text_inserttemplate = "Content Templates";
        if (!c.text_insertemoji) c.text_insertemoji = "Insert Emoji";
        if (!c.text_insertcode) c.text_insertcode = "Insert Code";
        if (!c.text_insertdocument) c.text_insertdocument = "Insert Document";
        if (!c.text_find) c.text_find = "Find & Replace";
        if (!c.text_bold) c.text_bold = "Bold";
        if (!c.text_italic) c.text_italic = "Italic";
        if (!c.text_underline) c.text_underline = "Underline";
        if (!c.text_removeformat) c.text_removeformat = "Remove Format";
        if (!c.text_cut) c.text_cut = "Cut";
        if (!c.text_copy) c.text_copy = "Copy";
        if (!c.text_paste) c.text_paste = "Paste";
        if (!c.text_delete) c.text_delete = "Delete";
        if (!c.text_undo) c.text_undo = "Undo";
        if (!c.text_redo) c.text_redo = "Redo";
        if (!c.text_selectall) c.text_selectall = "Select All";
        if (!c.text_preview) c.text_preview = "Preview";
        if (!c.text_previewtitle) c.text_previewtitle = "Preview";
        if (!c.text_previewnormal) c.text_previewnormal = "Desktop";
        if (!c.text_previewmobile) c.text_previewmobile = "Mobile";
        if (!c.text_previewtablet) c.text_previewtablet = "Tablet";
        if (!c.text_code) c.text_code = "Source Code";
        if (!c.text_print) c.text_print = "Print";
        if (!c.text_fullscreen) c.text_fullscreen = "Full Screen";
        if (!c.text_justifyleft) c.text_justifyleft = "Align Left";
        if (!c.text_justifycenter) c.text_justifycenter = "Align Center";
        if (!c.text_justifyright) c.text_justifyright = "Align Right";
        if (!c.text_justifyfull) c.text_justifyfull = "Justify";
        if (!c.text_insertorderedlist) c.text_insertorderedlist = "Ordered List";
        if (!c.text_insertunorderedlist) c.text_insertunorderedlist = "Unordered List";
        if (!c.text_indent) c.text_indent = "Indent";
        if (!c.text_outdent) c.text_outdent = "Outdent";
        if (!c.text_insertblockquote) c.text_insertblockquote = "Block Quote";
        if (!c.text_superscript) c.text_superscript = "Superscript";
        if (!c.text_subscript) c.text_subscript = "Subscript";
        if (!c.text_unlink) c.text_unlink = "Remove Link";
        if (!c.text_toggleborder) c.text_toggleborder = "Toggle Border";
        if (!c.text_save) c.text_save = "Save";
        if (!c.text_new) c.text_new = "New Document";
        if (!c.text_help) c.text_help = "Help";
        if (!c.text_insertanchor) c.text_insertanchor = "Insert Anchor";
        if (!c.text_insertdate) c.text_insertdate = "Insert Date";
        if (!c.text_cleancode) c.text_cleancode = "Clean Code";
        if (!c.text_fullscreenenter) c.text_fullscreenenter = "Full Screen";
        if (!c.text_fullscreenexit) c.text_fullscreenexit = "Exit Full Screen";
        if (!c.text_togglemore) c.text_togglemore = "More";
        if (!c.text_paragraphop) c.text_paragraphop = "Paragraph";
        if (!c.text_toggle_paragraphop) c.text_toggle_paragraphop = "Paragraph Options";
        if (!c.text_menu_paragraphop) c.text_menu_paragraphop = "Paragraph Menu";
        if (!c.text_paragraphstyle) c.text_paragraphstyle = "Paragraph Style";
        if (!c.text_inlinestyle) c.text_inlinestyle = "Inline Style";
        if (!c.text_styles) c.text_styles = "Styles";

        // Dialog UI strings
        if (!c.text_characters) c.text_characters = "Characters";
        if (!c.text_findwhat) c.text_findwhat = "Find What";
        if (!c.text_replacewith) c.text_replacewith = "Replace With";
        if (!c.text_matchcase) c.text_matchcase = "Match Case";
        if (!c.text_matchword) c.text_matchword = "Match Whole Word";
        if (!c.text_replaceonce) c.text_replaceonce = "Replace";
        if (!c.text_replaceall) c.text_replaceall = "Replace All";
        if (!c.text_findnext) c.text_findnext = "Find Next";
        if (!c.text_upload) c.text_upload = "Upload";
        if (!c.text_draganddrop) c.text_draganddrop = "Drag and drop a file here";
        if (!c.text_or) c.text_or = "or";
        if (!c.text_clicktoupload) c.text_clicktoupload = "Click to upload";
        if (!c.text_byurl) c.text_byurl = "By URL";
        if (!c.text_url) c.text_url = "URL";
        if (!c.text_size) c.text_size = "Size";
        if (!c.text_link) c.text_link = "Link";
        if (!c.text_text) c.text_text = "Text";
        if (!c.text_opennewwin) c.text_opennewwin = "Open in new window";
        if (!c.text_cancel) c.text_cancel = "Cancel";
        if (!c.text_insert) c.text_insert = "Insert";
        if (!c.text_update) c.text_update = "Update";
        if (!c.text_copied) c.text_copied = "Copied";
        if (!c.text_reachmaxlength) c.text_reachmaxlength = "Content has reached the maximum length";
        if (!c.text_pasteinstruction) c.text_pasteinstruction = "Press Ctrl+V to paste. Content will be cleaned automatically.";
        if (!c.text_defaultimagecaption) c.text_defaultimagecaption = "Image caption";
        if (!c.text_colorpicker) c.text_colorpicker = "Color Picker";
        if (!c.text_ok) c.text_ok = "OK";
        if (!c.text_colorwebpalette) c.text_colorwebpalette = "Web Palette";
        if (!c.text_colornamedcolors) c.text_colornamedcolors = "Named Colors";
        if (!c.text_colorbasic) c.text_colorbasic = "Basic";
        if (!c.text_coloraddition) c.text_coloraddition = "Additional";
        if (!c.text_close) c.text_close = "Close";
        if (!c.text_more) c.text_more = "More";

        // Paste submenu labels
        if (!c.text_pasteauto) c.text_pasteauto = "Paste";
        if (!c.text_pastetext) c.text_pastetext = "Paste as Text";
        if (!c.text_pasteword) c.text_pasteword = "Paste from Word";
        if (!c.text_ribbonpaste) c.text_ribbonpaste = "Paste";
        if (!c.text_ribbontable) c.text_ribbontable = "Table";

        // Office toolbar labels
        if (!c.text_justifymenu) c.text_justifymenu = "Align";
        if (!c.text_insertlinemenu) c.text_insertlinemenu = "Line Break";
        if (!c.text_underlinemenu) c.text_underlinemenu = "Underline";
        if (!c.text_pmore) c.text_pmore = "More";
        if (!c.text_plusbtn) c.text_plusbtn = "Add Block";

    }

    function normalizeText(value) {
        if (!value || value.indexOf("\uFFFD") === -1) {
            return value;
        }

        var exactTableSize = value.match(/^\s*(\d+)\s*\uFFFD+\s*(\d+)\s*$/);
        if (exactTableSize) {
            return exactTableSize[1] + " x " + exactTableSize[2];
        }

        return value.replace(/(\d)\s*\uFFFD+\s*(\d)/g, "$1 x $2");
    }

    function patchTextNode(node) {
        if (!node || node.nodeType !== Node.TEXT_NODE || !node.nodeValue) {
            return;
        }

        if (node.nodeValue.indexOf("\uFFFD") === -1) {
            return;
        }

        var parent = node.parentElement;
        if (!parent || parent.closest("[contenteditable='true']")) {
            return;
        }

        var nextValue = normalizeText(node.nodeValue);
        if (nextValue !== node.nodeValue) {
            node.nodeValue = nextValue;
        }
    }

    function enhanceInsertImagePanels(root) {
        if (!root || root.nodeType !== Node.ELEMENT_NODE) {
            return;
        }

        function bindPreview(urlInput, preview) {
            if (urlInput.__richtextboxPreviewBound) {
                return;
            }

            var image = preview.querySelector(".rte-insertimage-preview-image");
            var caption = preview.querySelector(".rte-insertimage-preview-caption");

            function updatePreview() {
                var value = urlInput.value.replace(/^\s+|\s+$/g, "");
                if (!value) {
                    preview.classList.add("is-empty");
                    preview.classList.remove("is-error");
                    image.removeAttribute("src");
                    caption.innerText = "Enter an image URL to preview it here.";
                    return;
                }

                preview.classList.remove("is-empty");
                preview.classList.remove("is-error");
                caption.innerText = "Loading preview...";
                image.src = value;
            }

            image.onload = function () {
                preview.classList.remove("is-empty");
                preview.classList.remove("is-error");
                caption.innerText = "Ready to insert this image.";
            };

            image.onerror = function () {
                preview.classList.remove("is-empty");
                preview.classList.add("is-error");
                caption.innerText = "Preview unavailable for this URL.";
            };

            urlInput.addEventListener("input", updatePreview);
            urlInput.__richtextboxPreviewBound = true;
            updatePreview();
        }

        var panels = [];
        if (root.classList && root.classList.contains("rte-panel-insertimage")) {
            panels.push(root);
        }

        var nestedPanels = root.querySelectorAll ? root.querySelectorAll(".rte-panel-insertimage") : [];
        for (var i = 0; i < nestedPanels.length; i++) {
            panels.push(nestedPanels[i]);
        }

        for (var panelIndex = 0; panelIndex < panels.length; panelIndex++) {
            var panel = panels[panelIndex];
            var uploadTab = panel.querySelector(".fileuploader-dragdrop");
            if (uploadTab && !uploadTab.querySelector(".rte-insertimage-intro")) {
                var uploadIntro = document.createElement("div");
                uploadIntro.className = "rte-insertimage-intro";
                uploadIntro.innerText = "Drop an image here or click anywhere in this panel to choose a file.";
                uploadTab.insertBefore(uploadIntro, uploadTab.firstChild);
            }

            var urlInput = panel.querySelector("rte-dialog-line-url input[type='text']");
            if (!urlInput) {
                continue;
            }

            var line = urlInput.parentElement;
            var tab = line ? line.parentElement : null;
            if (!tab) {
                continue;
            }

            if (!tab.querySelector(".rte-insertimage-intro")) {
                var intro = document.createElement("div");
                intro.className = "rte-insertimage-intro";
                intro.innerText = "Paste an image URL to preview it before inserting.";
                tab.insertBefore(intro, line);
            }

            var preview = tab.querySelector(".rte-insertimage-preview");
            if (!preview) {
                preview = document.createElement("div");
                preview.className = "rte-insertimage-preview is-empty";

                var previewImage = document.createElement("img");
                previewImage.className = "rte-insertimage-preview-image";
                preview.appendChild(previewImage);

                var previewCaption = document.createElement("div");
                previewCaption.className = "rte-insertimage-preview-caption";
                previewCaption.innerText = "Enter an image URL to preview it here.";
                preview.appendChild(previewCaption);

                if (line.nextSibling) {
                    tab.insertBefore(preview, line.nextSibling);
                } else {
                    tab.appendChild(preview);
                }
            }

            if (!urlInput.getAttribute("placeholder")) {
                urlInput.setAttribute("placeholder", "https://example.com/image.png");
            }
            bindPreview(urlInput, preview);
        }
    }

    function patchTree(root) {
        if (!root) {
            return;
        }

        if (root.nodeType === Node.TEXT_NODE) {
            patchTextNode(root);
            return;
        }

        if (root.nodeType !== Node.ELEMENT_NODE && root.nodeType !== Node.DOCUMENT_FRAGMENT_NODE) {
            return;
        }

        var walker = document.createTreeWalker(root, NodeFilter.SHOW_TEXT);
        var current = walker.nextNode();

        while (current) {
            patchTextNode(current);
            current = walker.nextNode();
        }

        if (root.nodeType === Node.ELEMENT_NODE) {
            enhanceInsertImagePanels(root);
        }
    }

    function injectPolishStyles() {
        if (document.getElementById('rte-polish-styles')) return;
        var style = document.createElement('style');
        style.id = 'rte-polish-styles';
        style.textContent = [
            /* ── Color picker polish ── */
            'rte-dropdown-panel.rte-panel-forecolor, rte-dropdown-panel.rte-panel-backcolor {',
            '  border-radius: 8px !important;',
            '  box-shadow: 0 8px 30px rgba(0,0,0,.12) !important;',
            '  padding: 12px 14px !important;',
            '  border: 1px solid #e2e8f0 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-header,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-header {',
            '  padding: 0 0 8px 0 !important;',
            '  border-bottom: 1px solid #f1f5f9 !important;',
            '  margin-bottom: 8px !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-header-text,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-header-text {',
            '  font-size: 13px !important;',
            '  font-weight: 600 !important;',
            '  color: #475569 !important;',
            '  text-transform: uppercase !important;',
            '  letter-spacing: 0.04em !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-item-color[rte-tooltip],',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-item-color[rte-tooltip] {',
            '  width: 20px !important;',
            '  height: 20px !important;',
            '  border-radius: 3px !important;',
            '  margin: 2px !important;',
            '  border: 1px solid rgba(0,0,0,.08) !important;',
            '  transition: transform .1s, box-shadow .1s !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-item-color[rte-tooltip]:hover,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-item-color[rte-tooltip]:hover {',
            '  transform: scale(1.25) !important;',
            '  box-shadow: 0 2px 8px rgba(0,0,0,.18) !important;',
            '  z-index: 1 !important;',
            '  position: relative !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-auto,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-auto,',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-more,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-more {',
            '  padding: 5px 4px !important;',
            '  margin-top: 4px !important;',
            '  border-radius: 4px !important;',
            '  cursor: pointer !important;',
            '  display: flex !important;',
            '  align-items: center !important;',
            '  gap: 6px !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-auto:hover,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-auto:hover,',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-more:hover,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-more:hover {',
            '  background: #f1f5f9 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-auto rte-dialog-item-label,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-auto rte-dialog-item-label,',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-more rte-dialog-item-label,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-more rte-dialog-item-label {',
            '  font-size: 13px !important;',
            '  color: #334155 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-auto rte-dialog-item-color,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-auto rte-dialog-item-color {',
            '  width: 20px !important;',
            '  height: 20px !important;',
            '  border-radius: 3px !important;',
            '  border: 1px solid #cbd5e1 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-forecolor rte-dialog-line-more rte-dialog-item-color,',
            'rte-dropdown-panel.rte-panel-backcolor rte-dialog-line-more rte-dialog-item-color {',
            '  width: 20px !important;',
            '  height: 20px !important;',
            '  border-radius: 3px !important;',
            '  border: 1px solid #cbd5e1 !important;',
            '  background: linear-gradient(135deg, #ff0000 0%, #ff8800 17%, #ffff00 33%, #00ff00 50%, #00ffff 67%, #0000ff 83%, #ff00ff 100%) !important;',
            '}',

            /* ── Insert chars dialog polish ── */
            'rte-dropdown-panel.rte-panel-insertchars {',
            '  border-radius: 8px !important;',
            '  box-shadow: 0 8px 30px rgba(0,0,0,.12) !important;',
            '  border: 1px solid #e2e8f0 !important;',
            '  padding: 0 !important;',
            '  overflow: hidden !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-dialog-header {',
            '  padding: 10px 16px !important;',
            '  border-bottom: none !important;',
            '  background: #f8fafc !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-dialog-header-text {',
            '  font-size: 13px !important;',
            '  font-weight: 600 !important;',
            '  color: #475569 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-tabui-toolbar {',
            '  padding: 0 12px !important;',
            '  gap: 0 !important;',
            '  background: #f8fafc !important;',
            '  border-bottom: 1px solid #e2e8f0 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-tabui-toolbar-button {',
            '  padding: 8px 10px !important;',
            '  font-size: 12px !important;',
            '  font-weight: 500 !important;',
            '  color: #64748b !important;',
            '  border-bottom: 2px solid transparent !important;',
            '  transition: color .15s, border-color .15s !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-tabui-toolbar-button:hover {',
            '  color: #0f172a !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-tabui-toolbar-button.rte-ui-active {',
            '  color: #0f8b8d !important;',
            '  border-bottom-color: #0f8b8d !important;',
            '  font-weight: 600 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-tabui-panel {',
            '  padding: 8px 12px !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-insertchars-item {',
            '  width: 28px !important;',
            '  height: 28px !important;',
            '  line-height: 28px !important;',
            '  font-size: 16px !important;',
            '  text-align: center !important;',
            '  border: 1px solid transparent !important;',
            '  border-radius: 4px !important;',
            '  cursor: pointer !important;',
            '  transition: background .1s, border-color .1s !important;',
            '}',
            'rte-dropdown-panel.rte-panel-insertchars rte-insertchars-item:hover {',
            '  background: #e0f2fe !important;',
            '  border-color: #93c5fd !important;',
            '}',

            /* ── Paragraph dropdown polish ── */
            'rte-dropdown-panel.rte-panel-paragraphs {',
            '  border-radius: 8px !important;',
            '  box-shadow: 0 8px 30px rgba(0,0,0,.12) !important;',
            '  border: 1px solid #e2e8f0 !important;',
            '}',
            'rte-dropdown-panel.rte-panel-paragraphs rte-dialog-header {',
            '  padding: 8px 14px !important;',
            '}',
            'rte-dropdown-panel.rte-panel-paragraphs rte-dialog-header-text {',
            '  font-size: 13px !important;',
            '  font-weight: 600 !important;',
            '  color: #475569 !important;',
            '}',

            /* ── Dialog input focus: grey instead of blue ── */
            '.richtextbox-host input:focus,',
            '.richtextbox-host select:focus,',
            '.richtextbox-host textarea:focus,',
            'rte-dropdown-panel input:focus,',
            'rte-dropdown-panel select:focus,',
            'rte-dropdown-panel textarea:focus,',
            'rte-dialog input:focus,',
            'rte-dialog select:focus,',
            'rte-dialog textarea:focus {',
            '  border-color: #94a3b8 !important;',
            '  outline: 2px solid #cbd5e1 !important;',
            '  outline-offset: -1px !important;',
            '  box-shadow: 0 0 0 3px rgba(148,163,184,.15) !important;',
            '}',

            /* ── Tag name selector buttons (match font-name/size dropdown style) ── */
            'rte-tagitem {',
            '  display: inline-flex !important;',
            '  align-items: center !important;',
            '  padding: 1px 6px !important;',
            '  margin: 2px !important;',
            '  font-size: 11px !important;',
            '  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;',
            '  color: #475569 !important;',
            '  background: #f8fafc !important;',
            '  border: 1px solid #e2e8f0 !important;',
            '  border-radius: 3px !important;',
            '  cursor: pointer !important;',
            '  line-height: 16px !important;',
            '  transition: background .1s, border-color .1s !important;',
            '}',
            'rte-tagitem:hover {',
            '  background: #e2e8f0 !important;',
            '  border-color: #cbd5e1 !important;',
            '  color: #1e293b !important;',
            '}',
            'rte-tagitem.rte-ui-active {',
            '  background: #e0f2fe !important;',
            '  border-color: #93c5fd !important;',
            '  color: #0369a1 !important;',
            '  font-weight: 500 !important;',
            '}',
            '',
            '/* Hide camera from insert image dialog */',
            '.rte_menuitem_cmd_insertimagebycamera { display: none !important; }',
            '.rte-panel-insertimage-camera { display: none !important; }',
            '.rte_insertimage_camera { display: none !important; }'
        ].join('\n');
        document.head.appendChild(style);
    }

    function start() {
        injectPolishStyles();
        patchTree(document.body);

        var observer = new MutationObserver(function (mutations) {
            for (var i = 0; i < mutations.length; i++) {
                var mutation = mutations[i];

                if (mutation.type === "characterData") {
                    patchTextNode(mutation.target);
                    continue;
                }

                for (var j = 0; j < mutation.addedNodes.length; j++) {
                    patchTree(mutation.addedNodes[j]);
                }
            }
        });

        observer.observe(document.documentElement, {
            childList: true,
            subtree: true,
            characterData: true
        });
    }

    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", start, { once: true });
        return;
    }

    start();
})();

// ─── Plugin: Direct Color Apply (for float toolbar) ─────────────────
RTE_DefaultConfig.svgCode_forecolordirect = RTE_DefaultConfig.svgCode_forecolor;
RTE_DefaultConfig.svgCode_backcolordirect = RTE_DefaultConfig.svgCode_backcolor;
RTE_DefaultConfig.text_forecolordirect = "Text Color";
RTE_DefaultConfig.text_backcolordirect = "Background Color";

RTE_DefaultConfig.plugin_forecolordirect = function () {
    var obj = this;
    obj.PluginName = "ForeColorDirect";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        var lastForeColor = "#ff0000";

        // Track the last-used forecolor from the main toolbar
        editor.attachEvent("exec_command_forecolor", function (state) {
            if (state.params && state.params[0]) {
                lastForeColor = state.params[0];
            }
        });

        editor.attachEvent("exec_command_forecolordirect", function (state) {
            var edDoc = editor.document;
            // Try to read the current color from the main toolbar's color mask
            var host = editor.container || null;
            if (host) {
                var mask = host.querySelector(".rte_command_forecolor rte-color-button-mask");
                if (mask && mask.style.backgroundColor) {
                    lastForeColor = mask.style.backgroundColor;
                }
            }
            edDoc.execCommand("foreColor", false, lastForeColor);
            state.returnValue = true;
        });

        editor.toolbarFactoryMap["forecolordirect"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

RTE_DefaultConfig.plugin_backcolordirect = function () {
    var obj = this;
    obj.PluginName = "BackColorDirect";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        var lastBackColor = "#ffff00";

        editor.attachEvent("exec_command_backcolor", function (state) {
            if (state.params && state.params[0]) {
                lastBackColor = state.params[0];
            }
        });

        editor.attachEvent("exec_command_backcolordirect", function (state) {
            var edDoc = editor.document;
            var host = editor.container || null;
            if (host) {
                var mask = host.querySelector(".rte_command_backcolor rte-color-button-mask");
                if (mask && mask.style.backgroundColor) {
                    lastBackColor = mask.style.backgroundColor;
                }
            }
            edDoc.execCommand("backColor", false, lastBackColor);
            state.returnValue = true;
        });

        editor.toolbarFactoryMap["backcolordirect"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Page Break ───────────────────────────────────────────────
RTE_DefaultConfig.plugin_insertpagebreak = function () {
    var obj = this;
    obj.PluginName = "InsertPageBreak";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_insertpagebreak", function (state) {
            editor.insertHTML('<div style="page-break-after:always;border-top:2px dashed #ccc;margin:16px 0;text-align:center;color:#999;font-size:12px;padding:4px 0;">— Page Break —</div><p><br/></p>');
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["insertpagebreak"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Case Change ──────────────────────────────────────────────
RTE_DefaultConfig.plugin_casechange = function () {
    var obj = this;
    obj.PluginName = "CaseChange";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.toolbarFactoryMap["casechange"] = function (cmd) {
            return editor.createToolbarItemDropDownPanel(cmd, function (panel) {
                panel.style.width = "180px";
                panel.style.padding = "4px";
                var options = [
                    { label: "UPPERCASE", fn: function (t) { return t.toUpperCase(); } },
                    { label: "lowercase", fn: function (t) { return t.toLowerCase(); } },
                    { label: "Title Case", fn: function (t) { return t.replace(/\S+/g, function (w) { return w.charAt(0).toUpperCase() + w.slice(1).toLowerCase(); }); } },
                    { label: "Sentence case", fn: function (t) { return t.charAt(0).toUpperCase() + t.slice(1).toLowerCase(); } },
                    { label: "tOGGLE cASE", fn: function (t) { return t.split("").map(function (ch) { return ch === ch.toUpperCase() ? ch.toLowerCase() : ch.toUpperCase(); }).join(""); } }
                ];
                for (var i = 0; i < options.length; i++) {
                    (function (opt) {
                        var btn = document.createElement("div");
                        btn.innerText = opt.label;
                        btn.style.cssText = "padding:6px 10px;cursor:pointer;border-radius:4px;font-size:13px;";
                        btn.onmouseover = function () { btn.style.backgroundColor = "#e8e8e8"; };
                        btn.onmouseout = function () { btn.style.backgroundColor = ""; };
                        btn.onclick = function () {
                            editor.closeCurrentPopup();
                            var edDoc = editor.document;
                            var sel = edDoc.defaultView.getSelection();
                            if (!sel || sel.isCollapsed) return;
                            var range = sel.getRangeAt(0);
                            var text = range.toString();
                            if (!text) return;
                            var newText = opt.fn(text);
                            range.deleteContents();
                            range.insertNode(edDoc.createTextNode(newText));
                            editor.focus();
                        };
                        panel.appendChild(btn);
                    })(options[i]);
                }
            });
        };
    };
};

// ─── Plugin: Format Painter ───────────────────────────────────────────
RTE_DefaultConfig.plugin_formatpainter = function () {
    var obj = this;
    obj.PluginName = "FormatPainter";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        var copiedStyles = null;
        var styleProps = ["fontWeight", "fontStyle", "textDecoration", "fontSize", "fontFamily", "color", "backgroundColor", "textAlign"];

        editor.attachEvent("exec_command_formatpainter", function (state) {
            var edDoc = editor.document;
            var sel = edDoc.defaultView.getSelection();
            if (!sel || sel.rangeCount === 0) return;

            if (copiedStyles) {
                // Apply phase
                if (sel.isCollapsed) { copiedStyles = null; state.returnValue = true; return; }
                var range = sel.getRangeAt(0);
                var span = edDoc.createElement("span");
                for (var j = 0; j < styleProps.length; j++) {
                    if (copiedStyles[styleProps[j]]) {
                        span.style[styleProps[j]] = copiedStyles[styleProps[j]];
                    }
                }
                try { range.surroundContents(span); } catch (e) { /* cross-element selection */ }
                copiedStyles = null;
                editor.focus();
            } else {
                // Copy phase
                var node = sel.anchorNode;
                if (node && node.nodeType === 3) node = node.parentElement;
                if (node) {
                    var computed = edDoc.defaultView.getComputedStyle(node);
                    copiedStyles = {};
                    for (var i = 0; i < styleProps.length; i++) {
                        copiedStyles[styleProps[i]] = computed[styleProps[i]];
                    }
                }
            }
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["formatpainter"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Bookmark ─────────────────────────────────────────────────
RTE_DefaultConfig.plugin_insertbookmark = function () {
    var obj = this;
    obj.PluginName = "InsertBookmark";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_insertbookmark", function (state) {
            var dialoginner = editor.createDialog("Insert Bookmark", "rte-dialog-insertbookmark");
            dialoginner.style.padding = "16px";
            var label = document.createElement("label");
            label.innerText = "Bookmark name:";
            label.style.cssText = "display:block;margin-bottom:6px;font-size:13px;font-weight:600;";
            dialoginner.appendChild(label);
            var input = document.createElement("input");
            input.type = "text";
            input.placeholder = "e.g. section1";
            input.style.cssText = "width:100%;padding:6px 10px;border:1px solid #ccc;border-radius:4px;font-size:13px;box-sizing:border-box;";
            dialoginner.appendChild(input);
            var btnRow = document.createElement("div");
            btnRow.style.cssText = "margin-top:12px;text-align:right;";
            var insertBtn = document.createElement("button");
            insertBtn.innerText = "Insert";
            insertBtn.style.cssText = "padding:6px 18px;background:#0f8b8d;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;";
            insertBtn.onclick = function () {
                var name = input.value.replace(/[^a-zA-Z0-9_-]/g, "").replace(/^\s+|\s+$/g, "");
                if (name) {
                    editor.insertHTML('<a id="' + name + '" name="' + name + '" class="rte-bookmark" style="background:#ffeeba;padding:0 3px;border-radius:2px;font-size:11px;">&#128278;' + name + '</a>');
                }
                dialoginner.close();
                editor.focus();
            };
            btnRow.appendChild(insertBtn);
            dialoginner.appendChild(btnRow);
            setTimeout(function () { input.focus(); }, 100);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["insertbookmark"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: To-Do List ───────────────────────────────────────────────
RTE_DefaultConfig.plugin_inserttodolist = function () {
    var obj = this;
    obj.PluginName = "InsertTodoList";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_inserttodolist", function (state) {
            var html = '<ul style="list-style:none;padding-left:4px;margin:8px 0;">';
            for (var i = 0; i < 3; i++) {
                html += '<li style="margin:4px 0;"><label style="display:inline-flex;align-items:center;gap:6px;cursor:pointer;"><input type="checkbox" style="width:16px;height:16px;accent-color:#0f8b8d;cursor:pointer;"/><span>Task item</span></label></li>';
            }
            html += '</ul><p><br/></p>';
            editor.insertHTML(html);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["inserttodolist"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Table of Contents ────────────────────────────────────────
RTE_DefaultConfig.plugin_inserttoc = function () {
    var obj = this;
    obj.PluginName = "InsertTOC";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_inserttoc", function (state) {
            var edDoc = editor.document;
            var headings = edDoc.querySelectorAll("h1,h2,h3,h4,h5,h6");
            if (headings.length === 0) {
                editor.insertHTML('<div style="padding:12px;background:#fff3cd;border:1px solid #ffc107;border-radius:4px;color:#856404;font-size:13px;">No headings found. Add headings (H1–H6) to generate a Table of Contents.</div>');
                state.returnValue = true;
                return;
            }
            var tocHtml = '<div class="rte-toc" style="background:#f8f9fa;border:1px solid #dee2e6;border-radius:6px;padding:16px 20px;margin:12px 0;">';
            tocHtml += '<p style="font-weight:700;font-size:15px;margin:0 0 10px;">Table of Contents</p>';
            tocHtml += '<ul style="list-style:none;padding:0;margin:0;">';
            for (var i = 0; i < headings.length; i++) {
                var h = headings[i];
                var level = parseInt(h.tagName.charAt(1));
                var text = h.innerText || h.textContent || "";
                var id = "toc-heading-" + i;
                h.setAttribute("id", id);
                var indent = (level - 1) * 16;
                tocHtml += '<li style="margin:3px 0;padding-left:' + indent + 'px;"><a href="#' + id + '" style="color:#0f8b8d;text-decoration:none;font-size:13px;">' + text + '</a></li>';
            }
            tocHtml += '</ul></div><p><br/></p>';
            editor.insertHTML(tocHtml);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["inserttoc"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Merge Fields ─────────────────────────────────────────────
RTE_DefaultConfig.plugin_insertmergefield = function () {
    var obj = this;
    obj.PluginName = "InsertMergeField";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.toolbarFactoryMap["insertmergefield"] = function (cmd) {
            return editor.createToolbarItemDropDownPanel(cmd, function (panel) {
                panel.style.width = "200px";
                panel.style.padding = "4px";
                var fields = [
                    { label: "First Name", value: "{{FirstName}}" },
                    { label: "Last Name", value: "{{LastName}}" },
                    { label: "Email", value: "{{Email}}" },
                    { label: "Company", value: "{{Company}}" },
                    { label: "Date", value: "{{Date}}" },
                    { label: "Phone", value: "{{Phone}}" },
                    { label: "Address", value: "{{Address}}" },
                    { label: "City", value: "{{City}}" },
                    { label: "Custom Field...", value: "" }
                ];
                for (var i = 0; i < fields.length; i++) {
                    (function (field) {
                        var btn = document.createElement("div");
                        btn.innerText = field.label;
                        btn.style.cssText = "padding:6px 10px;cursor:pointer;border-radius:4px;font-size:13px;";
                        btn.onmouseover = function () { btn.style.backgroundColor = "#e8e8e8"; };
                        btn.onmouseout = function () { btn.style.backgroundColor = ""; };
                        btn.onclick = function () {
                            editor.closeCurrentPopup();
                            if (field.value) {
                                editor.insertHTML('<span class="rte-merge-field" contenteditable="false" style="background:#e3f2fd;border:1px solid #90caf9;border-radius:3px;padding:1px 6px;font-size:12px;color:#1565c0;white-space:nowrap;">' + field.value + '</span>&nbsp;');
                            } else {
                                var name = prompt("Enter field name:");
                                if (name) {
                                    editor.insertHTML('<span class="rte-merge-field" contenteditable="false" style="background:#e3f2fd;border:1px solid #90caf9;border-radius:3px;padding:1px 6px;font-size:12px;color:#1565c0;white-space:nowrap;">{{' + name.replace(/[{}]/g, "") + '}}</span>&nbsp;');
                                }
                            }
                            editor.focus();
                        };
                        panel.appendChild(btn);
                    })(fields[i]);
                }
            });
        };
    };
};

// ─── Plugin: Footnotes ────────────────────────────────────────────────
RTE_DefaultConfig.plugin_insertfootnote = function () {
    var obj = this;
    var footnoteCounter = 0;
    obj.PluginName = "InsertFootnote";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_insertfootnote", function (state) {
            var dialoginner = editor.createDialog("Insert Footnote", "rte-dialog-insertfootnote");
            dialoginner.style.padding = "16px";
            var label = document.createElement("label");
            label.innerText = "Footnote text:";
            label.style.cssText = "display:block;margin-bottom:6px;font-size:13px;font-weight:600;";
            dialoginner.appendChild(label);
            var textarea = document.createElement("textarea");
            textarea.placeholder = "Enter footnote text...";
            textarea.style.cssText = "width:100%;height:80px;padding:8px;border:1px solid #ccc;border-radius:4px;font-size:13px;box-sizing:border-box;resize:vertical;";
            dialoginner.appendChild(textarea);
            var btnRow = document.createElement("div");
            btnRow.style.cssText = "margin-top:12px;text-align:right;";
            var insertBtn = document.createElement("button");
            insertBtn.innerText = "Insert";
            insertBtn.style.cssText = "padding:6px 18px;background:#0f8b8d;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;";
            insertBtn.onclick = function () {
                var text = textarea.value.replace(/^\s+|\s+$/g, "");
                if (text) {
                    footnoteCounter++;
                    var n = footnoteCounter;
                    editor.insertHTML('<sup class="rte-footnote-ref" style="color:#0f8b8d;cursor:pointer;font-weight:700;" data-footnote="' + n + '">[' + n + ']</sup>');
                    // Append footnote to bottom
                    var edDoc = editor.document;
                    var footnotesDiv = edDoc.querySelector(".rte-footnotes");
                    if (!footnotesDiv) {
                        footnotesDiv = edDoc.createElement("div");
                        footnotesDiv.className = "rte-footnotes";
                        footnotesDiv.style.cssText = "border-top:1px solid #dee2e6;margin-top:24px;padding-top:12px;font-size:12px;color:#666;";
                        var title = edDoc.createElement("p");
                        title.style.cssText = "font-weight:700;font-size:13px;margin:0 0 6px;";
                        title.innerText = "Footnotes";
                        footnotesDiv.appendChild(title);
                        edDoc.body.appendChild(footnotesDiv);
                    }
                    var fnEntry = edDoc.createElement("p");
                    fnEntry.style.cssText = "margin:2px 0;font-size:12px;";
                    fnEntry.innerHTML = '<sup style="font-weight:700;color:#0f8b8d;">[' + n + ']</sup> ' + text;
                    footnotesDiv.appendChild(fnEntry);
                }
                dialoginner.close();
                editor.focus();
            };
            btnRow.appendChild(insertBtn);
            dialoginner.appendChild(btnRow);
            setTimeout(function () { textarea.focus(); }, 100);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["insertfootnote"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Spell Check Toggle ───────────────────────────────────────
RTE_DefaultConfig.plugin_spellcheck = function () {
    var obj = this;
    obj.PluginName = "SpellCheck";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_spellcheck", function (state) {
            var edDoc = editor.document;
            var body = edDoc.body;
            var current = body.getAttribute("spellcheck");
            var enable = current !== "true";
            body.setAttribute("spellcheck", enable ? "true" : "false");
            body.focus();
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["spellcheck"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Import from Word ─────────────────────────────────────────
RTE_DefaultConfig.plugin_importword = function () {
    var obj = this;
    obj.PluginName = "ImportWord";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_importword", function (state) {
            var dialoginner = editor.createDialog("Import from Word", "rte-dialog-importword");
            dialoginner.style.padding = "16px";
            var intro = document.createElement("p");
            intro.style.cssText = "font-size:13px;color:#555;margin:0 0 12px;";
            intro.innerText = "Paste content from Microsoft Word or any document below. Formatting will be cleaned and preserved.";
            dialoginner.appendChild(intro);
            var pasteArea = document.createElement("div");
            pasteArea.contentEditable = "true";
            pasteArea.style.cssText = "width:100%;min-height:200px;max-height:400px;overflow:auto;padding:10px;border:2px dashed #ccc;border-radius:6px;font-size:13px;box-sizing:border-box;outline:none;";
            pasteArea.setAttribute("placeholder", "Paste here (Ctrl+V)...");
            dialoginner.appendChild(pasteArea);
            var btnRow = document.createElement("div");
            btnRow.style.cssText = "margin-top:12px;text-align:right;";
            var insertBtn = document.createElement("button");
            insertBtn.innerText = "Insert";
            insertBtn.style.cssText = "padding:6px 18px;background:#0f8b8d;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;";
            insertBtn.onclick = function () {
                var html = pasteArea.innerHTML || "";
                // Clean Word-specific markup
                html = html.replace(/<!--[\s\S]*?-->/g, "");
                html = html.replace(/<style[\s\S]*?<\/style>/gi, "");
                html = html.replace(/<xml[\s\S]*?<\/xml>/gi, "");
                html = html.replace(/<o:[\s\S]*?<\/o:[^>]*>/gi, "");
                html = html.replace(/class="Mso[^"]*"/gi, "");
                html = html.replace(/\s*mso-[^:]+:[^;"]+;?/gi, "");
                html = html.replace(/<\/?span[^>]*>/gi, function (m) {
                    return m.indexOf("style") > -1 ? m : "";
                });
                if (html) {
                    editor.insertHTML(html);
                }
                dialoginner.close();
                editor.focus();
            };
            btnRow.appendChild(insertBtn);
            dialoginner.appendChild(btnRow);
            setTimeout(function () { pasteArea.focus(); }, 100);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["importword"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Export to PDF (wrapper for html2pdf) ─────────────────────
RTE_DefaultConfig.plugin_exportpdf = function () {
    var obj = this;
    obj.PluginName = "ExportPDF";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_exportpdf", function (state) {
            // Delegate to html2pdf command if available
            if (editor.toolbarFactoryMap["html2pdf"]) {
                editor.execCommand("html2pdf");
            } else {
                // Fallback: print-based PDF
                var edDoc = editor.document;
                var win = edDoc.defaultView || edDoc.parentWindow;
                if (win) win.print();
            }
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["exportpdf"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Export to Word ───────────────────────────────────────────
RTE_DefaultConfig.plugin_exportword = function () {
    var obj = this;
    obj.PluginName = "ExportWord";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_exportword", function (state) {
            var html = editor.getHTMLCode();
            var wordHtml = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"><title>Document</title></head><body>' + html + '</body></html>';
            var blob = new Blob(['\ufeff', wordHtml], { type: "application/msword" });
            var url = URL.createObjectURL(blob);
            var a = document.createElement("a");
            a.href = url;
            a.download = "document.doc";
            document.body.appendChild(a);
            a.click();
            document.body.removeChild(a);
            URL.revokeObjectURL(url);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["exportword"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: @Mentions ────────────────────────────────────────────────
RTE_DefaultConfig.plugin_insertmention = function () {
    var obj = this;
    obj.PluginName = "InsertMention";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_insertmention", function (state) {
            var dialoginner = editor.createDialog("Insert @Mention", "rte-dialog-insertmention");
            dialoginner.style.padding = "16px";
            var label = document.createElement("label");
            label.innerText = "Username or name:";
            label.style.cssText = "display:block;margin-bottom:6px;font-size:13px;font-weight:600;";
            dialoginner.appendChild(label);
            var input = document.createElement("input");
            input.type = "text";
            input.placeholder = "e.g. john.doe";
            input.style.cssText = "width:100%;padding:6px 10px;border:1px solid #ccc;border-radius:4px;font-size:13px;box-sizing:border-box;";
            dialoginner.appendChild(input);
            var btnRow = document.createElement("div");
            btnRow.style.cssText = "margin-top:12px;text-align:right;";
            var insertBtn = document.createElement("button");
            insertBtn.innerText = "Insert";
            insertBtn.style.cssText = "padding:6px 18px;background:#0f8b8d;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;";
            insertBtn.onclick = function () {
                var name = input.value.replace(/^\s+|\s+$/g, "");
                if (name) {
                    editor.insertHTML('<span class="rte-mention" contenteditable="false" style="background:#e8f5e9;border:1px solid #a5d6a7;border-radius:3px;padding:1px 6px;font-size:13px;color:#2e7d32;white-space:nowrap;">@' + name + '</span>&nbsp;');
                }
                dialoginner.close();
                editor.focus();
            };
            btnRow.appendChild(insertBtn);
            dialoginner.appendChild(btnRow);
            setTimeout(function () { input.focus(); }, 100);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["insertmention"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Insert Comment ───────────────────────────────────────────
RTE_DefaultConfig.plugin_insertcomment = function () {
    var obj = this;
    obj.PluginName = "InsertComment";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_insertcomment", function (state) {
            var edDoc = editor.document;
            var sel = edDoc.defaultView.getSelection();
            var selectedText = sel && !sel.isCollapsed ? sel.toString() : "";

            var dialoginner = editor.createDialog("Add Comment", "rte-dialog-insertcomment");
            dialoginner.style.padding = "16px";
            if (selectedText) {
                var preview = document.createElement("div");
                preview.style.cssText = "background:#f5f5f5;border-left:3px solid #0f8b8d;padding:8px 12px;margin-bottom:12px;font-size:12px;color:#555;border-radius:0 4px 4px 0;max-height:60px;overflow:hidden;";
                preview.innerText = selectedText.substring(0, 120) + (selectedText.length > 120 ? "..." : "");
                dialoginner.appendChild(preview);
            }
            var label = document.createElement("label");
            label.innerText = "Comment:";
            label.style.cssText = "display:block;margin-bottom:6px;font-size:13px;font-weight:600;";
            dialoginner.appendChild(label);
            var textarea = document.createElement("textarea");
            textarea.placeholder = "Type your comment...";
            textarea.style.cssText = "width:100%;height:80px;padding:8px;border:1px solid #ccc;border-radius:4px;font-size:13px;box-sizing:border-box;resize:vertical;";
            dialoginner.appendChild(textarea);
            var btnRow = document.createElement("div");
            btnRow.style.cssText = "margin-top:12px;text-align:right;";
            var insertBtn = document.createElement("button");
            insertBtn.innerText = "Add Comment";
            insertBtn.style.cssText = "padding:6px 18px;background:#0f8b8d;color:#fff;border:none;border-radius:4px;cursor:pointer;font-size:13px;";
            insertBtn.onclick = function () {
                var comment = textarea.value.replace(/^\s+|\s+$/g, "");
                if (comment && selectedText) {
                    var range = sel.getRangeAt(0);
                    var mark = edDoc.createElement("mark");
                    mark.style.cssText = "background:#fff9c4;border-bottom:2px solid #f9a825;cursor:pointer;position:relative;";
                    mark.setAttribute("title", comment);
                    mark.setAttribute("data-comment", comment);
                    try { range.surroundContents(mark); } catch (e) {}
                } else if (comment) {
                    editor.insertHTML('<span class="rte-comment-marker" contenteditable="false" style="background:#fff9c4;border:1px solid #f9a825;border-radius:3px;padding:1px 6px;font-size:11px;color:#f57f17;cursor:pointer;" title="' + comment.replace(/"/g, "&quot;") + '">&#128172; Comment</span>');
                }
                dialoginner.close();
                editor.focus();
            };
            btnRow.appendChild(insertBtn);
            dialoginner.appendChild(btnRow);
            setTimeout(function () { textarea.focus(); }, 100);
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["insertcomment"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Track Changes (visual toggle) ───────────────────────────
RTE_DefaultConfig.plugin_trackchanges = function () {
    var obj = this;
    obj.PluginName = "TrackChanges";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        var tracking = false;
        editor.attachEvent("exec_command_trackchanges", function (state) {
            tracking = !tracking;
            var edDoc = editor.document;
            if (tracking) {
                edDoc.body.setAttribute("data-tracking", "true");
                edDoc.body.style.outline = "2px solid #4caf50";
                edDoc.body.style.outlineOffset = "-2px";
                // Listen for input events to mark changes
                edDoc.body.__rte_input_handler = function () {
                    var sel = edDoc.defaultView.getSelection();
                    if (sel && sel.anchorNode) {
                        var node = sel.anchorNode.nodeType === 3 ? sel.anchorNode.parentElement : sel.anchorNode;
                        if (node && !node.closest("[data-tracked]")) {
                            node.style.borderLeft = "2px solid #4caf50";
                            node.setAttribute("data-tracked", "inserted");
                        }
                    }
                };
                edDoc.body.addEventListener("input", edDoc.body.__rte_input_handler);
            } else {
                edDoc.body.removeAttribute("data-tracking");
                edDoc.body.style.outline = "";
                edDoc.body.style.outlineOffset = "";
                if (edDoc.body.__rte_input_handler) {
                    edDoc.body.removeEventListener("input", edDoc.body.__rte_input_handler);
                    edDoc.body.__rte_input_handler = null;
                }
            }
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["trackchanges"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Revision History ─────────────────────────────────────────
RTE_DefaultConfig.plugin_revisionhistory = function () {
    var obj = this;
    var revisions = [];
    obj.PluginName = "RevisionHistory";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        // Auto-save revisions periodically
        var saveInterval = setInterval(function () {
            try {
                var html = editor.getHTMLCode();
                if (revisions.length === 0 || revisions[revisions.length - 1].html !== html) {
                    revisions.push({ html: html, time: new Date() });
                    if (revisions.length > 50) revisions.shift();
                }
            } catch (e) {}
        }, 30000); // Every 30 seconds

        editor.attachEvent("exec_command_revisionhistory", function (state) {
            // Save current state
            var currentHtml = editor.getHTMLCode();
            if (revisions.length === 0 || revisions[revisions.length - 1].html !== currentHtml) {
                revisions.push({ html: currentHtml, time: new Date() });
            }

            var dialoginner = editor.createDialog("Revision History", "rte-dialog-revisionhistory");
            dialoginner.style.padding = "16px";
            dialoginner.style.minWidth = "400px";

            if (revisions.length <= 1) {
                var noRevisions = document.createElement("p");
                noRevisions.style.cssText = "color:#666;font-size:13px;text-align:center;padding:20px;";
                noRevisions.innerText = "No previous revisions yet. Revisions are saved automatically every 30 seconds.";
                dialoginner.appendChild(noRevisions);
            } else {
                var list = document.createElement("div");
                list.style.cssText = "max-height:300px;overflow:auto;";
                for (var i = revisions.length - 1; i >= 0; i--) {
                    (function (rev, idx) {
                        var item = document.createElement("div");
                        item.style.cssText = "padding:8px 12px;border-bottom:1px solid #eee;cursor:pointer;font-size:13px;display:flex;justify-content:space-between;align-items:center;";
                        item.onmouseover = function () { item.style.backgroundColor = "#f5f5f5"; };
                        item.onmouseout = function () { item.style.backgroundColor = ""; };
                        var timeStr = rev.time.toLocaleTimeString() + " " + rev.time.toLocaleDateString();
                        var label = document.createElement("span");
                        label.innerText = (idx === revisions.length - 1 ? "Current" : "Revision " + (idx + 1));
                        var time = document.createElement("span");
                        time.style.cssText = "color:#999;font-size:11px;";
                        time.innerText = timeStr;
                        item.appendChild(label);
                        item.appendChild(time);
                        if (idx < revisions.length - 1) {
                            item.onclick = function () {
                                if (confirm("Restore this revision? Current content will be replaced.")) {
                                    editor.setHTMLCode(rev.html);
                                    dialoginner.close();
                                    editor.focus();
                                }
                            };
                        }
                        list.appendChild(item);
                    })(revisions[i], i);
                }
                dialoginner.appendChild(list);
            }
            state.returnValue = true;
        });
        editor.toolbarFactoryMap["revisionhistory"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Autoformatting (Markdown shortcuts) ──────────────────────
RTE_DefaultConfig.plugin_autoformatting = function () {
    var obj = this;
    var enabled = true;
    obj.PluginName = "Autoformatting";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.attachEvent("exec_command_autoformatting", function (state) {
            enabled = !enabled;
            state.returnValue = true;
        });

        // Listen for Space key to detect markdown patterns
        editor.attachEvent("ContentReady", function () {
            var edDoc = editor.document;
            edDoc.addEventListener("keydown", function (e) {
                if (!enabled || e.key !== " " && e.key !== "Enter") return;
                var sel = edDoc.defaultView.getSelection();
                if (!sel || !sel.anchorNode || sel.anchorNode.nodeType !== 3) return;
                var textNode = sel.anchorNode;
                var text = textNode.textContent;
                var offset = sel.anchorOffset;
                var lineText = text.substring(0, offset);

                // Only process at beginning of block
                var block = textNode.parentElement;
                if (!block) return;
                var isFirstChild = block.firstChild === textNode || (block.firstChild && block.firstChild.nextSibling === textNode && block.firstChild.nodeType !== 3);

                if (!isFirstChild && block.childNodes[0] !== textNode) return;

                var replacement = null;

                if (e.key === " ") {
                    // Heading shortcuts: # → H1, ## → H2, etc.
                    var headingMatch = lineText.match(/^(#{1,6})$/);
                    if (headingMatch) {
                        e.preventDefault();
                        var level = headingMatch[1].length;
                        textNode.textContent = text.substring(offset);
                        var p = block.closest("p,div,h1,h2,h3,h4,h5,h6");
                        if (p && p.parentElement) {
                            var heading = edDoc.createElement("h" + level);
                            while (p.firstChild) heading.appendChild(p.firstChild);
                            p.parentElement.replaceChild(heading, p);
                            var range = edDoc.createRange();
                            range.setStart(heading, 0);
                            range.collapse(true);
                            sel.removeAllRanges();
                            sel.addRange(range);
                        }
                        return;
                    }

                    // Blockquote: >
                    if (lineText === ">") {
                        e.preventDefault();
                        textNode.textContent = text.substring(offset);
                        var p = block.closest("p,div");
                        if (p && p.parentElement) {
                            var bq = edDoc.createElement("blockquote");
                            bq.style.cssText = "border-left:3px solid #ccc;margin:8px 0;padding:4px 12px;color:#555;";
                            while (p.firstChild) bq.appendChild(p.firstChild);
                            p.parentElement.replaceChild(bq, p);
                        }
                        return;
                    }

                    // Horizontal rule: ---
                    if (lineText === "---" || lineText === "***") {
                        e.preventDefault();
                        textNode.textContent = text.substring(offset);
                        var p = block.closest("p,div");
                        if (p && p.parentElement) {
                            var hr = edDoc.createElement("hr");
                            p.parentElement.replaceChild(hr, p);
                        }
                        return;
                    }

                    // Unordered list: - or *
                    if (lineText === "-" || lineText === "*") {
                        e.preventDefault();
                        textNode.textContent = text.substring(offset);
                        edDoc.execCommand("insertUnorderedList");
                        return;
                    }

                    // Ordered list: 1.
                    if (lineText === "1.") {
                        e.preventDefault();
                        textNode.textContent = text.substring(offset);
                        edDoc.execCommand("insertOrderedList");
                        return;
                    }

                    // Checkbox / to-do: []
                    if (lineText === "[]") {
                        e.preventDefault();
                        var p = block.closest("p,div");
                        if (p) {
                            p.innerHTML = '<label style="display:inline-flex;align-items:center;gap:6px;cursor:pointer;"><input type="checkbox" style="width:16px;height:16px;accent-color:#0f8b8d;cursor:pointer;"/><span>&nbsp;</span></label>';
                        }
                        return;
                    }
                }
            });
        });

        editor.toolbarFactoryMap["autoformatting"] = function (cmd) {
            return editor.createToolbarButton(cmd);
        };
    };
};

// ─── Plugin: Multi-level List ─────────────────────────────────────────
RTE_DefaultConfig.plugin_multilevellist = function () {
    var obj = this;
    obj.PluginName = "MultiLevelList";
    obj.InitConfig = function () {};
    obj.InitEditor = function (editor) {
        editor.toolbarFactoryMap["multilevellist"] = function (cmd) {
            return editor.createToolbarItemDropDownPanel(cmd, function (panel) {
                panel.style.width = "200px";
                panel.style.padding = "8px";
                var listTypes = [
                    { label: "Numbered (1, 2, 3)", type: "decimal" },
                    { label: "Alpha (a, b, c)", type: "lower-alpha" },
                    { label: "Alpha Upper (A, B, C)", type: "upper-alpha" },
                    { label: "Roman (i, ii, iii)", type: "lower-roman" },
                    { label: "Roman Upper (I, II, III)", type: "upper-roman" },
                    { label: "Disc", type: "disc" },
                    { label: "Circle", type: "circle" },
                    { label: "Square", type: "square" }
                ];
                for (var i = 0; i < listTypes.length; i++) {
                    (function (lt) {
                        var btn = document.createElement("div");
                        btn.style.cssText = "padding:5px 10px;cursor:pointer;border-radius:4px;font-size:13px;";
                        btn.innerText = lt.label;
                        btn.onmouseover = function () { btn.style.backgroundColor = "#e8e8e8"; };
                        btn.onmouseout = function () { btn.style.backgroundColor = ""; };
                        btn.onclick = function () {
                            editor.closeCurrentPopup();
                            var isOrdered = lt.type !== "disc" && lt.type !== "circle" && lt.type !== "square";
                            var edDoc = editor.document;
                            edDoc.execCommand(isOrdered ? "insertOrderedList" : "insertUnorderedList");
                            var sel = edDoc.defaultView.getSelection();
                            if (sel && sel.anchorNode) {
                                var list = sel.anchorNode.nodeType === 3 ? sel.anchorNode.parentElement : sel.anchorNode;
                                var ul = list ? list.closest("ul,ol") : null;
                                if (ul) {
                                    ul.style.listStyleType = lt.type;
                                }
                            }
                            editor.focus();
                        };
                        panel.appendChild(btn);
                    })(listTypes[i]);
                }
            });
        };
    };

    // Patch powerby link to point to richtextbox.com
    var patchPowerBy = function () {
        var links = document.querySelectorAll("rte-powerby a, .rte-powerby a");
        for (var i = 0; i < links.length; i++) {
            if (links[i].href.indexOf("richtexteditor.com") !== -1) {
                links[i].href = "https://richtextbox.com";
                links[i].textContent = "richtextbox";
            }
        }
    };
    if (document.readyState === "loading") {
        document.addEventListener("DOMContentLoaded", function () { setTimeout(patchPowerBy, 500); });
    } else {
        setTimeout(patchPowerBy, 500);
    }
    setInterval(patchPowerBy, 2000);

};
