concrete5 rich text editor with plain text and image only functionality
Permalink
concrete5 has a pretty rich text editor. Can it be stripped to plain text and insert image only functionality?
In the Dashboard -> System & Settings -> Rich Text Editor you can remove many items. If you uncheck all except the ones you want it should get close to this, I'm not sure which options will be left but it won't be many.
Those changes are global. I'm wondering if the c5 RTE can be stripped only in a package.
I do not believe that this can be done easily.
I did it in a package this way.
So first the idea is
1- deselect all the plugins you don't want
2- output your editor
3- reselect the plugins that were selected if needed
So first the idea is
1- deselect all the plugins you don't want
2- output your editor
3- reselect the plugins that were selected if needed
$editor = $app->make('editor'); $pluginManager = $editor->getPluginManager(); $selectedPlugins = $pluginManager->getSelectedPlugins(); $allowedPlugins = ['image', 'image2']; // here you need to know the handles of the plugins you want $pluginsToDeselect = array_diff($selectedPlugins, $allowedPlugins); $pluginManager->deselect($pluginsToDeselect); echo $editor->outputStandardEditor('editorHandle', $editorValue); // if memory serves this last step is not always allowed. If you have more editors on the same page that should be displayed normally then you need to reselect the plugins that you deselected. Otherwise deselecting them this way doesn't affect other sessions so no need to select them again. But to be verified, I might be wrong. $pluginManager->select($pluginsToDeselect);
That did the trick. Thank you for the idea. I had to add a 'wysiwygarea' plugin, otherwise the editor and all buttons are locked.
Although that sort of did what I asked, but that's not quite what I meant :)
The image button in the editor allows access to the file manager. I was wondering how I can simply paste an image from a clipboard (same way as I can do in the page editor), not from the FM. I need an editor where I can only type text and insert an image from a clipboard. Is this possible? If it's not possible, do you know which plugin is required for HTML input (you know the one which you click to show html and then click back to show text?). I guess I can then strip all tags except for the img.
I also find the Paste button doesn't work with the plugins removed, it says "Press Ctrl+V to paste. Your browser doesn‘t support pasting with the toolbar button or context menu option." Do you know which plugin is for pasting?
Although that sort of did what I asked, but that's not quite what I meant :)
The image button in the editor allows access to the file manager. I was wondering how I can simply paste an image from a clipboard (same way as I can do in the page editor), not from the FM. I need an editor where I can only type text and insert an image from a clipboard. Is this possible? If it's not possible, do you know which plugin is required for HTML input (you know the one which you click to show html and then click back to show text?). I guess I can then strip all tags except for the img.
I also find the Paste button doesn't work with the plugins removed, it says "Press Ctrl+V to paste. Your browser doesn‘t support pasting with the toolbar button or context menu option." Do you know which plugin is for pasting?
the cut/copy/paste functions require the plugin "clipboard". If you go to your editor page /dashboard/system/basics/editor you can check the value for each checkbox, that's the handle for each plugin.
Concerning the image, what you are asking poses a challenge. Where would your image be once you pasted it in your content? The image has to be somewhere physically right? Either in a random spot on your server or in the file manager.
The only possibility to paste an image and to have it somewhere physically would be that the plugin turns it into a data:image. If you look in the Ckeditor marketplace you might find something like that.
Concerning the image, what you are asking poses a challenge. Where would your image be once you pasted it in your content? The image has to be somewhere physically right? Either in a random spot on your server or in the file manager.
The only possibility to paste an image and to have it somewhere physically would be that the plugin turns it into a data:image. If you look in the Ckeditor marketplace you might find something like that.
@mnakalay, your previous post actually turned out to be what I needed :)
I was viewing the editor box as an admin and thus had the full access to the file manager, sitemap etc. And it's ok for the admin. But a standard user doesn't have that access, so the image upload is from a path, not from the FM, and no access to the site map. So that's all good.
Nearly there. If I allow the standard RTE with all default options - all is good. But if remove all the plugins, then I have an editor with the left plugins for an admin and just a textbox for a user. What am I missing to show the stripped version of the RTE to the user?
And how can I modify its toolbar? At the moment I have cut/copy/paste buttons showing for admin, but not for a user. Why is this different? I have these plugins enabled:
I only have 3 buttons for users and 6 for admin - see attached
I was viewing the editor box as an admin and thus had the full access to the file manager, sitemap etc. And it's ok for the admin. But a standard user doesn't have that access, so the image upload is from a path, not from the FM, and no access to the site map. So that's all good.
Nearly there. If I allow the standard RTE with all default options - all is good. But if remove all the plugins, then I have an editor with the left plugins for an admin and just a textbox for a user. What am I missing to show the stripped version of the RTE to the user?
And how can I modify its toolbar? At the moment I have cut/copy/paste buttons showing for admin, but not for a user. Why is this different? I have these plugins enabled:
$allowedPlugins = ['wysiwygarea', 'image', 'image2', 'undo', 'toolbar', 'pastetext', 'clipboard'];
I only have 3 buttons for users and 6 for admin - see attached
When going t your Editor settings page in the dashboard are the plugins you need checked by default? If not try to check them by default and see if it fixes the problem.
And without running that code, do the clipboard buttons show for guest users?
And without running that code, do the clipboard buttons show for guest users?
Actually I just discovered my code above is not totally correct. Try this instead and see if it fixes the problem.
$editor = $app->make('editor'); $pluginManager = $editor->getPluginManager(); $selectedPlugins = $pluginManager->getSelectedPlugins(); $allowedPlugins = ['wysiwygarea', 'image', 'image2', 'undo', 'toolbar', 'pastetext', 'clipboard']; // here you need to know the handles of the plugins you want $pluginManager->deselect($selectedPlugins); $pluginManager->select($allowedPlugins); echo $editor->outputStandardEditor('editorHandle', $editorValue); // if memory serves this last step is not always required. If you have more editors on the same page that should be displayed normally then you need to reselect the plugins that you deselected. Otherwise deselecting them this way doesn't affect other sessions so no need to select them again. But to be verified, I might be wrong. $pluginManager->deselect($allowedPlugins); $pluginManager->select($selectedPlugins);
That's great! Exactly what I needed. Thank you very much!