Forum

Thread tagged as: Question, Redactor

Adding Classes via Redactor

Possible? I know the Redactor developers have some plugins and 'Clips' might be pressed into service, but doesn't seem possible to add to the Perch implementation (unless I'm missing something obvious and this post qualifies me for the evening's 'hard of understanding' award).

Miles Cruickshank

Miles Cruickshank 0 points

  • 7 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Redactor in Perch is just Redactor - it's no different.

Hmm. Okay. I tried adding the redactor clips stylesheet and js to the redactor folder and updated the _config.inc file to pointer to them, but the WYSIWYG editor isn't seem to 'pick them up.' Perhaps I mistyped or misunderstood the path syntax.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Did you get any errors in your browser console? Anything you can tell me at all that might give a clue?

Hi, Sorry to take so long to get back to you.

Path in generated html appears to be correct:

<script type="text/javascript" src="/perch/addons/plugins/editors/redactor/redactor/redactor.min.js"></script> <script type="text/javascript" src="/perch/addons/plugins/editors/redactor/redactor/clips.js"></script> <link rel="stylesheet" href="/perch/addons/plugins/editors/redactor/redactor/redactor.css" type="text/css" /> <link rel="stylesheet" href="/perch/addons/plugins/editors/redactor/redactor/clips.css" type="text/css" />

But in the console it shows 404 error for absolute URLs of:

https://www.milesismy.name/perch/core/apps/content/edit/PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/clips.js https://www.milesismy.name/perch/core/apps/content/edit/PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/clips.css

Have tried numerous variations in the redactor/_config.inc file, now probably going 'code-blind' after staring at it too long.

Any ideas?

Drew McLellan

Drew McLellan 2638 points
Perch Support

What do you have in the _config.inc file now?

<script type="text/javascript" src="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/redactor.min.js"></script>
<script type="text/javascript" src="/perch/addons/plugins/editors/redactor/redactor/clips.js"></script>
<link rel="stylesheet" href="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/redactor.css" type="text/css" />
<link rel="stylesheet" href="/perch/addons/plugins/editors/redactor/redactor/clips.css" type="text/css" />

Tried a number of variations on the path, no joy.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It should be:

<script type="text/javascript" src="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/redactor.min.js"></script>
<script type="text/javascript" src="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/clips.js"></script>
<link rel="stylesheet" href="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/redactor.css" type="text/css" />
<link rel="stylesheet" href="PERCH_LOGINPATH/addons/plugins/editors/redactor/redactor/clips.css" type="text/css" />

Yup, tried that before, but I think I was inadvertently over-writing it and causing the 404 errors by also having (and forgetting about) some code in plugins/ui/-config.inc. Have now deleted that and 404 errors are resolved.

Still don't see the 'clips' icon in the redactor toolbar though.In their example, there's an additional toolbar link of:

<li><a href="javascript:;" title="Clips" tabindex="-1" class="re-icon re-clips redactor-btn-image"></a></li>

Don't see how to add that within Perch (assuming I need to).

Is there another way of allowing end-users to add pre-defined text classes?

Drew McLellan

Drew McLellan 2638 points
Perch Support

I'd imagine you'd need to add the functionality to the editor config as well as just linking the files. Have you done that part?

Nope. Wasn't clear (to me at any rate) how to, and at the moment I don't have time for another round of trial and error.

Previous comment about another method was tongue in cheek, but is there a means of offering end-users a means of adding classes via one of the alternative editors? I don't know a great deal about Markdown or Textile, but couldn't see a means of adding there either. Wouldn't have thought it a unique requirement?

But appreciate your help meantime. Might come back to it later when I've got more time and am again in the mood for banging my head against a wall...

I know it's do-able in CK editor, but given that's a bit of a clunkfest IMO, I'm not particularly keen to go down that road again.

Drew McLellan

Drew McLellan 2638 points
Perch Support

If it's for images, you can do that with the imageclasses attribute for MarkItUp with Textile or Markdown.

Nope, purely for text classes. Once again, appreciate your input, obviously this isn't primarily a Perch issue.

Cheers meantime.