在Liferay的编辑器中安装插件

时间:2017-08-01 09:58:07

标签: liferay liferay-dxp

我有Liferay DXP安装,我想在编辑器中安装一个插件。该插件为base64image

我关注this official guide所以我创建了一个类似这样的类:

@Component(immediate = true, service = DynamicInclude.class)
public class CKEditorBase64ImageDynamicInclude implements DynamicInclude {

        private BundleContext bundleContext;


        @Override
        public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException {
                Bundle bundle = bundleContext.getBundle();
                URL entryURL = bundle.getEntry("/META-INF/resources/html/editors/ckeditor/extension/base64_images.js");
                StreamUtil.transfer(entryURL.openStream(), response.getOutputStream());
        }

        @Override
        public void register(DynamicIncludeRegistry dynamicIncludeRegistry) {
                dynamicIncludeRegistry.register("com.liferay.frontend.editors.web#ckeditor#onEditorCreate");

        }

        @Activate
        protected void activate(BundleContext bundleContext) {
                this.bundleContext = bundleContext;
        }

}

它应该包含初始化编辑器的base64_images.js文件。但无论文件的内容是什么,它都无法运行。这有什么问题?

我想补充一点,插件文件(JavaScript代码)是我Liferay主题的一部分。我希望base64_images.js调用它的API,但它也可能不是正确的方法。

0 个答案:

没有答案