Skip to content

Instantly share code, notes, and snippets.

@FishOfPrey
Last active November 26, 2015 00:46
Show Gist options
  • Save FishOfPrey/197db9dfed9b5f195c9e to your computer and use it in GitHub Desktop.
Save FishOfPrey/197db9dfed9b5f195c9e to your computer and use it in GitHub Desktop.
Chrome Extension to replace the standard CKEditor configuration with one of my control in the Salesforce success forums
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
//return {redirectUrl: 'https://developer.salesforce.com/forums/ckeditor/ckeditor-5.x/rel/sfdc-config.js'};
return {redirectUrl: 'https://na5.salesforce.com/resource/1447106281000/DFB__sfdcConfig'};
},
{
urls: [
"https://developer.salesforce.com/forums/ckeditor/ckeditor-4.x/rel/sfdc-config.js",
"https://developer.salesforce.com/forums/ckeditor/ckeditor-4.x/rel/sfdc-config.js?t=4.4.6.4"
],
types: ["script", "main_frame", "sub_frame", "stylesheet", "image", "object", "xmlhttprequest", "other"]
},
["blocking"]
);
// Chrome Extension Version
alert('injected');
CKEDITOR.editorConfig = function(a) {
a.toolbarCanCollapse = true;
a.resize_enabled = true;
a.enterMode = CKEDITOR.ENTER_BR;
a.shiftEnterMode = CKEDITOR.ENTER_P;
a.forcePasteAsPlainText = true;
a.forceSimpleAmpersand = true;
a.pasteFromWordRemoveFontStyles = true;
a.pasteFromWordRemoveStyles = true;
a.imageUploadAllowedExtensions = ".(jpg|gif|jpeg|png|bmp|jfif|jpe|pjpeg)$";
a.imageUploadDeniedExtensions = "";
var b = [];
b.push("div{*}(*); span{*}(*); p{*}(*); br{*}(*); hr{*}(*);");
b.push("h1{*}(*); h2{*}(*); h3{*}(*); h4{*}(*); h5{*}(*); h6{*}(*);");
b.push("a[*]{*}(*);");
b.push("img[!src,alt,width,height,border]{*}(*);");
b.push("font[face,size,color];");
b.push("strike; s; b; em; strong; i; big; small; sub; sup; blockquote; ins; kbd; pre{*}(*); tt;");
b.push("abbr; acronym; address; bdo; caption; cite; code; col; colgroup;");
b.push("dd; del; dfn; dl; dt; q; samp; var;");
b.push("table{*}(*)[align,border,cellpadding,cellspacing,summary];");
b.push("caption{*}(*); tbody{*}(*); thead{*}(*); tfoot{*}(*);");
b.push("th{*}(*)[scope,colspan,rowspan,align,valign]; tr{*}(*)[align,valign]; td{*}(*)[scope,colspan,rowspan,align,valign];");
a.extraAllowedContent = b.join(" ");
a.coreStyles_strike = {
element: "strike"
};
a.coreStyles_bold = {
element: "b"
};
a.coreStyles_italic = {
element: "i"
};
//a.removePlugins = "elementspath,maximize,resize,image,liststyle,tabletools,contextmenu";
a.removePlugins = "elementspath,maximize,resize,image,liststyle,tabletools,contextmenu,scayt,menubutton";
a.disableNativeSpellChecker = false;
a.extraPlugins = "sfdcImage,sfdcMediaEmbed,sfdcSmartLink,sfdcCodeBlock,sfdcTable,sfdcVfAjax4J";
//a.removeDialogTabs = "link:advanced;table:advanced;tableProperties:advanced";
a.toolbar_SalesforceBasic = [
["Undo", "Redo"],
["Bold", "Italic", "Underline", "Strike"],
["-", "Link", "sfdcImage"],
["-",
"JustifyLeft", "JustifyCenter", "JustifyRight"
],
["-", "BulletedList", "NumberedList"],
["Indent", "Outdent"]
];
a.toolbar_SalesforceLight = [
["Bold", "Italic"],
["Link"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList"],
["FontSize"]
];
a.toolbar_EmailMultiFormat = [
["SfdcSwitchToText"],
["RemoveFormat", "TextColor", "BGColor"],
["Bold", "Italic", "Underline", "Strike"],
["sfdcImage"],
["Link", "Unlink", "Anchor"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"],
["Font", "FontSize", "Format"]
];
a.toolbar_Email = [
["RemoveFormat", "TextColor", "BGColor"],
["Bold", "Italic", "Underline", "Strike"],
["sfdcImage"],
["Link", "Unlink", "Anchor"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"],
["Font", "FontSize", "Format"]
];
a.toolbar_Knowledge = [
["Source"],
["Undo", "Redo"], "Bold Italic Underline Strike - RemoveFormat".split(" "), ["Table", "sfdcCodeBlock"],
["sfdcSmartLink", "Link", "Unlink", "Anchor"],
["sfdcImage"],
["JustifyLeft", "JustifyCenter",
"JustifyRight"
],
["BulletedList", "NumberedList", "Indent", "Outdent"],
["Format", "Font", "FontSize", "TextColor", "BGColor"]
];
a.toolbar_KnowledgeWithIframes = [
["Source"],
["Undo", "Redo"], "Bold Italic Underline Strike - RemoveFormat".split(" "), ["Table", "sfdcCodeBlock"],
["sfdcSmartLink", "Link", "Unlink", "Anchor"],
["sfdcImage", "sfdcMediaEmbed"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"],
["Format", "Font", "FontSize", "TextColor", "BGColor"]
];
a.toolbar_Visualforce = [
["Undo", "Redo"],
["Bold", "Italic", "Underline", "Strike"],
["Link", "sfdcImage"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"]
];
a.toolbar_HomePageComponent = [
["Undo", "Redo"],
["Bold", "Italic", "Underline", "Strike"],
["Table"],
["Link", "sfdcImage"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"],
["Font", "FontSize", "TextColor", "BGColor"]
];
a.toolbar_ServiceCommunity = [
["Source", "RemoveFormat"],
["Undo", "Redo"],
["Bold", "Italic", "Underline", "Strike"],
["Link", "sfdcImage", "sfdcCodeBlock"],
["JustifyLeft", "JustifyCenter", "JustifyRight"],
["BulletedList", "NumberedList", "Indent", "Outdent"]
];
a.plugins = "about,a11yhelp,basicstyles,bidi,blockquote,clipboard,colorbutton,colordialog,contextmenu,dialogadvtab,div,elementspath,enterkey,entities,filebrowser,find,flash,floatingspace,font,format,forms,horizontalrule,htmlwriter,image,iframe,indentlist,indentblock,justify,language,link,list,liststyle,magicline,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,resize,save,selectall,showblocks,showborders,smiley,sourcearea,specialchar,stylescombo,tab,table,tabletools,templates,toolbar,undo,wysiwygarea"
};
{
"name": "Salesforce Forum Spellchecker",
"description": "Replace CKEditor config.js to enable spell checking",
"version": "1.0",
"manifest_version": 1,
"background": {"scripts":["background.js"]},
"permissions": [
"webRequest",
"https://developer.salesforce.com/*",
"webRequestBlocking"
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment