-
Hey, we're using craft as headless CMS in some cases. Therefore we often remove the "link to entry" and "link to file" option in WYSIWYG fields, since users can't only reference real URLs in our projects. For redactor, we removed the "link to an entry" and "link to a file" option via PHP in a module: Event::on(
RedactorField::class,
RedactorField::EVENT_REGISTER_LINK_OPTIONS,
function (RegisterLinkOptionsEvent $event) {
$defaultOptions = $event->linkOptions;
// Search for "Link to Entry" element
$entryLink = ArrayHelper::where($defaultOptions, 'elementType', 'craft\\elements\\Entry');
// remove it
$updatedOptions = ArrayHelper::without($defaultOptions, key($entryLink));
// Search for "Link to File"
$fileLink = ArrayHelper::where($defaultOptions, 'elementType', 'craft\\elements\\Asset');
// remove if user has access to it
if (count($fileLink) > 0) {
$updatedOptions = ArrayHelper::without($updatedOptions, key($fileLink));
}
$event->linkOptions = $updatedOptions;
// reindex array
$event->linkOptions = array_values($event->linkOptions);
}
); What is the best way to remove this option in ckeditor? (The link to file option is not shown when I remove the allowed volumes in the ckeditor field configuration settings) Thanks very much in advance! 👋 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi, there’s
|
Beta Was this translation helpful? Give feedback.
Hi, there’s
EVENT_DEFINE_LINK_OPTIONS
, which you can use to do the same thing.