Advertisement:

Author Topic: Adding a plugin to SMF 2.1 SCEditor  (Read 257 times)

Offline JavaJones

  • Semi-Newbie
  • *
  • Posts: 19
Adding a plugin to SMF 2.1 SCEditor
« on: August 14, 2019, 02:10:52 PM »
Is it possible to add any of the SCEditor plugins to SMF 2.1's version of the editor? I want to install this plugin:
https://www.sceditor.com/documentation/plugins/plaintext/ [nofollow]


I am attempting to follow the instructions but can't find that exact instantiation text anywhere in SMF's code. The closest I find is:

Code: [Select]
   sceditor.create = function (textarea, options) {
      // Call the original create function
      createFn(textarea, options);

Which is inside jquery.sceditor.smf.js

I'm unclear how to modify this similar but not identical code to call the plugin, or if the version of SCEditor in SMF even includes this plugin functionality.


- Oshyan



Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,414
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Adding a plugin to SMF 2.1 SCEditor (
« Reply #1 on: August 14, 2019, 02:14:55 PM »
Go to Sources/Subs-Editor.php

look for
Code: [Select]
$sce_options = array(
'style' => $settings[file_exists($settings['theme_dir'] . '/css/jquery.sceditor.default.css') ? 'theme_url' : 'default_theme_url'] . '/css/jquery.sceditor.default.css',
'emoticonsCompat' => true,
'colors' => 'black,maroon,brown,green,navy,grey,red,orange,teal,blue,white,hotpink,yellow,limegreen,purple',
'format' => 'bbcode',
'plugins' => '',
'bbcodeTrim' => true,
);

add your plugin name there

Imazighen

Offline JavaJones

  • Semi-Newbie
  • *
  • Posts: 19
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #2 on: August 14, 2019, 02:24:11 PM »
Man, the support on this forum is awesome, thanks for the quick reply!

Unfortunately it does not seem to have any effect, or at least not the effect I expected. Pasting text still pastes it with formatting. Do you know if this plugin is included in the SMF 2.1 version of SCEditor, or a way I might find out?

- Oshyan

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,414
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #3 on: August 14, 2019, 02:36:54 PM »
Yea you also have to upload plaintext.js to Themes/default/scripts and then load it using

Code: [Select]
loadJavaScriptFile('plaintext.js');
you can past that before the code above, it should work.

This can be made into a mod pretty easily, I think I'll make it.

Imazighen

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,414
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #4 on: August 14, 2019, 03:34:25 PM »
Try this
https://github.com/SychO9/smf-sce-plaintext/releases/tag/v1.0

Download the plaintext-v1.0.zip file and install it as a mod.

Imazighen

Offline JavaJones

  • Semi-Newbie
  • *
  • Posts: 19
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #5 on: August 14, 2019, 06:09:08 PM »
Thanks so much! I had made the code changes manually but just undid them because maintaining it as a mod should be easier. I really appreciate your quick work here.

I'd encourage you to publicize this more widely, too. Because default paste behavior is frankly terrible, hah. If I am writing a post in WYSIWYG and switch to the plain text view, I see just my text. If I switch back to WYSIWYG, copy text from my post, then paste the text further down in the editor, and switch back to plain text, suddenly my pasted text has a bunch of formatting! And if I then post it with no further modification, my original text and copied text end up with different formatting (slight visual difference), even though one was copied from the other. Seems quite "off" to me.

Anyway, instead of complain about that (which I realize I've just done, hah), I thought I'd just try to fix it with the plain text plugin.

Thanks again!

- Oshyan

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,414
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #6 on: August 14, 2019, 06:14:35 PM »
You're welcome :)

I'd encourage you to publicize this more widely, too.

Yes this shall go into the mod site.

Imazighen

Offline JavaJones

  • Semi-Newbie
  • *
  • Posts: 19
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #7 on: August 14, 2019, 06:20:12 PM »
Hmm, ok so I got this error when trying to upload that as a mod via Package Manager:

An error has occurred
You did not select a package to upload.

But uploading it manually to the Packages directory worked. Just thought I'd mention it in case there's any adjustment you need to make. Could be something on my end.

- Oshyan

Offline SychO

  • Lead Customizer
  • SMF Hero
  • *
  • Posts: 1,414
  • Gender: Male
    • SychO9 on GitHub
    • SychO
Re: Adding a plugin to SMF 2.1 SCEditor
« Reply #8 on: August 14, 2019, 06:27:59 PM »
Your Packages folder might not be writable, its CHMOD needs to be set at 755 I believe

Imazighen