Permalink
Browse files

added forceNL plugin to convert <br /> to newline

  • Loading branch information...
1 parent 9d78dfa commit 0e9c78e349977ac4e8cddea25ecf4190b01e6b33 @MSchmidt MSchmidt committed with Mar 30, 2010
Showing with 27 additions and 0 deletions.
  1. +1 −0 js/punymce/plugins/forcenl.js
  2. +26 −0 js/punymce/plugins/forcenl_src.js

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,26 @@
+// ForceNL Plugin for PunyMCE
+// - Converts all <br /> to \n
+punymce.plugins.ForceNL = function(ed) {
+ // Forces <br /> to \n
+ ed.onGetContent.add(function(ed, o) {
+ if (o.format == 'forcenl' || o.save) {
+ punymce.each([
+ [/<(br\s*\/)>/gi, "\n"],
+ [/<(br.*?\/)>/gi, ""]
+ //[<br type="_moz"/>, ""]
+ ], function (v) {
+ o.content = o.content.replace(v[0], v[1]);
+ });
+ }
+ });
+
+ ed.onSetContent.add(function(ed, o) {
+ if (o.format == 'forcenl' || o.load) {
+ punymce.each([
+ [/\n/gi,"<br />"]
+ ], function (v) {
+ o.content = o.content.replace(v[0], v[1]);
+ });
+ }
+ });
+};

0 comments on commit 0e9c78e

Please sign in to comment.