Please login or register.

Login with username, password and session length
Advanced search  

News:

You need/want an older version of sNews ? Download an older/unsupported version here.

Pages: 1 [2]

Author Topic: [MOD]Auto <p> <br> </p> for editor  (Read 6431 times)

Joost

  • Guest
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #15 on: March 25, 2008, 10:22:23 pm »

It doesn't work properly with [break] either
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #16 on: March 27, 2008, 03:25:37 pm »

maybe better left as a mod then...
Although, it is also just in thesimple editor.
For more editor options, installation of 3rd party wysiwyg would be the way to go.
Logged
Of all the things I have lost, it is my mind that I miss the most.

Fred K

  • Still trying to learn stuff
  • ULTIMATE member
  • ******
  • Karma: 130
  • Posts: 2728
    • Personal
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #17 on: March 28, 2008, 07:10:32 pm »

Quote from: philmoz
All other formatting tags are kept in place and presented in the editor window.

In my tests that is only true for the editor "button"-made tags. Hand written tags are erased in the output. Try using <abbr> for example. Or <blockquote>.

Naturally, there's always the option that I've done something wrong... ;)
Logged

ens

  • Sr. Member
  • ****
  • Karma: 12
  • Posts: 279
    • http://www.meatysite.info
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #18 on: March 30, 2008, 09:19:13 pm »

Sometimes I make custom pages using the editor and would not benefit from this mod... however, I WOULD benefit during article-writing time...

So like most others have suggested -- YES it should be included, but instead of the p, br buttons at the bottom, one for "disable automatic breaks, etc" or something of the like. A "graceful fallback", as they say... you know.. when you don't have javascript enabled but things still work... agh.
Logged

invarbrass

  • Full Member
  • ***
  • Karma: 18
  • Posts: 117
    • http://snews.extremebittorrent.com
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #19 on: April 01, 2008, 09:11:18 pm »

this is a good mod. might be useful for a few people.
alternatively, someone had incorporated the texy parser into snews.
Logged

fcam

  • Newbie
  • *
  • Karma: 0
  • Posts: 13
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #20 on: May 03, 2008, 08:14:20 pm »

I've tried adding this mod several times and it didn't work at all.

The textarea disappears everytime.

I modified the 3 functions then added the 2 new functions just like it said.

Does it matter where the new functions go? Any ideas?

as soon as I replace the old line with:
echo html_input('textarea', 'text', 'txt', remove_tags($frm_text), l('text'), '', '', '', '', '', '2', '100', '', '', '');

The textarea disappears. If I put back in the old line, the textarea comes back.
« Last Edit: May 03, 2008, 08:28:01 pm by fcam »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #21 on: May 03, 2008, 08:27:51 pm »

Does it matter where the new functions go? Any ideas?

No, but must be outside of any other function.
Functions are like this:

function one(){
......
}

here you insert the two other functions, between the functions, not inside

function two(){
.......
}


If you know this, ignore this reply.
Anyway, you can post more details about your sNews? What other mods you use, what version of sNews, etc....
Logged

fcam

  • Newbie
  • *
  • Karma: 0
  • Posts: 13
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #22 on: May 03, 2008, 08:31:50 pm »

Thanks,

I would never knowingly put it inside another function. I put the 2 new functions right after:

I am using sNews 1.6 with no other mods at this time.

// generate preview NEW MODIFIED FUNCTION
   function updatePreview() {
      if (document.getElementById('txt')) {
         var body = document.getElementById('txt').value;
         body = body.replace(/(\r\n\r\n|\r\r|\n\n)/g, "<p>");
         body = body.replace(/(\r\n|\r|\n)/g, "<br />");
         document.getElementById('preview').innerHTML = body;
      }
   }

//Editor functions. NEW FUNCTIONS HERE
« Last Edit: May 03, 2008, 08:37:11 pm by fcam »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #23 on: May 03, 2008, 08:36:42 pm »

Well function updatePreview()
have a special place... it replace another function with the same name.... and you must put it right in the place where you found the old function...

Another two functions are php functions and you can put them in the middle of file snews.php but between functions.
Logged

fcam

  • Newbie
  • *
  • Karma: 0
  • Posts: 13
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #24 on: May 03, 2008, 08:38:44 pm »

I replaced the old preview function with the new one in the same place.

here is the actual code with the old one commented out:

   // generate preview - same as 1.5.31.
//   function updatePreview() {
//      if (document.getElementById('txt')) {
//         var body = document.getElementById('txt').value;
//         document.getElementById('preview').innerHTML = body;
//      }
//   }

// generate preview. MODIFIED FUNCTION
   function updatePreview() {
      if (document.getElementById('txt')) {
         var body = document.getElementById('txt').value;
         body = body.replace(/(\r\n\r\n|\r\r|\n\n)/g, "<p>");
         body = body.replace(/(\r\n|\r|\n)/g, "<br />");
         document.getElementById('preview').innerHTML = body;
      }
   }

Thanks
« Last Edit: May 03, 2008, 08:40:45 pm by fcam »
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #25 on: May 03, 2008, 08:46:00 pm »

As you see, the function updatePreview() is inside php function js() because updatePreview is Javascript code.

If you want, the other two functions you can put them before function js().
Logged

fcam

  • Newbie
  • *
  • Karma: 0
  • Posts: 13
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #26 on: May 03, 2008, 08:57:55 pm »

Thank you, that was the problem. That js is a long function and I was inside of it. I moved the new functions above the start of the Javascript functions and now it works.

Thanks!!
Logged

funlw65

  • Hero Member
  • *****
  • Karma: 96
  • Posts: 771
    • Country Lab
Re: [MOD]Auto <p> <br> </p> for editor
« Reply #27 on: May 03, 2008, 09:58:49 pm »

Welcome! Glad to help.
Logged
Pages: 1 [2]