[MGNLUI-2727] Rich-text field - when using custom config.js file, the magnolialink plugin is not available Created: 03/Mar/14  Updated: 11/Aug/15  Resolved: 16/Sep/14

Status: Closed
Project: Magnolia UI
Component/s: None
Affects Version/s: 5.2.2
Fix Version/s: None

Type: Bug Priority: Neutral
Reporter: Bence Vass Assignee: Mikaël Geljić
Resolution: Duplicate Votes: 4
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File MGNLUI-2727.png    
Issue Links:
causality
duplicate
is duplicated by MGNLUI-3150 Make sure CKEditor magnolialink plugi... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   

When using a custom config.js file for the Rich-text field (CKEditor), the magnolialink plugin is not loaded (and thus DamLink and InternalLink are not available for the CKEditor). Configuring the plugin in config.js is possible, but the necessary eventlistener will still be missing.

Possible solution:
Load the plugin and its eventlistener when a custom config.js file is found (in RichTextFieldFactory.java, maybe make this behaviour configurable).



 Comments   
Comment by Bence Vass [ 04/Mar/14 ]

Always loading the plugin is problematic too, because then you can't load plugins from the custom config.js.

Comment by Moritz Siuts [ 02/Jun/14 ]

Is there a workaround to use a custom config and the magnolialink plugin?

Comment by Mikaël Geljić [ 16/Sep/14 ]

Hi there,

I linked this issue to superseding ticket MGNLUI-3150 (which was created from another SUPPORT ticket).
I will tentatively close this issue and keep tracking progress on MGNLUI-3150; feel free to reopen if you feel it doesn't address your concerns.

Meanwhile would you mind confirming whether a 5.2.x fix is still required (SUPPORT-3976 hints at 5.3.2)?

Cheers,

Comment by Moritz Siuts [ 16/Sep/14 ]

A workaround to this issue is to extend info.magnolia.dam.asset.field.factory.AssetsEnabledRichTextFieldFactory and override the methods initializeToolbarConfig and initializeCKEditorConfig to configure the CKEditor and add some custom plugins.

Then you use your own class as factory class for Textareas at config/modules/ui-framework/fieldTypes/textArea

Comment by Matteo Pelucco [ 10/Aug/15 ]

Here a working class, HTH (It would have helped me )

package com.package.info;

import info.magnolia.dam.api.AssetProviderRegistry;
import info.magnolia.dam.app.ui.field.factory.AssetsEnabledRichTextFieldFactory;
import info.magnolia.i18nsystem.SimpleTranslator;
import info.magnolia.ui.api.app.AppController;
import info.magnolia.ui.api.context.UiContext;
import info.magnolia.ui.form.field.definition.RichTextFieldDefinition;
import info.magnolia.ui.vaadin.integration.contentconnector.ContentConnector;
import info.magnolia.ui.vaadin.richtext.MagnoliaRichTextFieldConfig;

import com.vaadin.data.Item;
import com.vaadin.server.VaadinService;

/**
 * Custom RichTextFieldFactory, able to instantiate magnolialink controls to CKEditor even in case of custom
 * configJsFile property. More infos here: https://jira.magnolia-cms.com/browse/MGNLUI-2727
 * 
 * @author matteo
 *
 */
public class MyProjectAssetsEnabledRichTextFieldFactory extends AssetsEnabledRichTextFieldFactory {

	public static final String ASSET_CHOSEN_EVENT_ID = "assetChosen";

	private static final String PLUGIN_NAME_MAGNOLIALINK = "magnolialink";
	private static final String PLUGIN_PATH_MAGNOLIALINK = "/VAADIN/js/magnolialink/";

	public MyProjectAssetsEnabledRichTextFieldFactory(RichTextFieldDefinition definition, Item relatedFieldItem, AppController appController, UiContext uiContext, SimpleTranslator i18n,
	    AssetProviderRegistry assetProviderRegistry, ContentConnector contentConnector) {
		super(definition, relatedFieldItem, appController, uiContext, i18n, assetProviderRegistry, contentConnector);
	}

	protected MagnoliaRichTextFieldConfig initializeCKEditorConfig() {

		MagnoliaRichTextFieldConfig config = super.initializeCKEditorConfig();

		String path = VaadinService.getCurrentRequest().getContextPath();

		// add this in any case
		config.addPlugin(PLUGIN_NAME_MAGNOLIALINK, path + PLUGIN_PATH_MAGNOLIALINK);
		config.addListenedEvent(EVENT_GET_MAGNOLIA_LINK);

		return config;
	}

}

Comment by Matteo Pelucco [ 10/Aug/15 ]

..and this is the configuration under config workspace (ui-framework module)

Comment by Mikaël Geljić [ 11/Aug/15 ]

Hi Matteo,

This is exactly what's done inside the RichTextFieldFactory itself. This was resolved in 5.3.4, with superseding ticket MGNLUI-3150.
Commit says:

MGNLUI-3150 register magnolialink plugin on the server-side at all time, so that custom config.js can use it

So my question is, are you stuck with an older version of Magnolia? Or is there still a scenario where this is not working as intended?

Cheers,
Mika

Comment by Matteo Pelucco [ 11/Aug/15 ]

Hi Mika,
unfortunately yes, stuck with that version for a period of time and we need that feature.
It is working fine. I've just updated this task to help other people in my situation to quickly solve this issue.

M.

Comment by Mikaël Geljić [ 11/Aug/15 ]

Perfect then, thanks for sharing and glad if that works for you.
(Hopefully you don't have to stick with 5.2 for too long!)

Generated at Mon Feb 12 08:59:33 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.