Created
March 29, 2018 11:32
-
-
Save ryandemmer/eddf46e8e2cd8e582452afcb81140449 to your computer and use it in GitHub Desktop.
Replace editor content
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tinyMCE.onAddEditor.add(function (mgr, ed) { | |
ed.onInit.add(function () { | |
function updateContent(content) { | |
content = content.replace(/\b(jce)\b/gi, function(match, value) { | |
return value.toUpperCase(); | |
}); | |
content = content.replace(/\b(january)\b/gi, function(match, value) { | |
return '<strong>' + value + '</strong>'; | |
}); | |
content = content.replace(/\b(march)\b/gi, function(match, value) { | |
return '<span style="color:green">' + value + '</span>'; | |
}); | |
return content; | |
} | |
ed.onSetContent.add(function (ed, o) { | |
o.content = updateContent(o.content); | |
}); | |
ed.onGetContent.add(function (ed, o) { | |
o.content = updateContent(o.content); | |
}); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment