WYSIWYGエディターの動的インクルード

すべてのWYSIWYGエディターは、次の操作について同じ動的インクルードの拡張ポイントを共有します。

  • エディターへのリソース、プラグインなどの追加:

    com.liferay.frontend.editor.editorType.web#editorName#additionalResources

  • エディターインスタンスへのアクセスによるイベントのリッスン、設定など:

    com.liferay.frontend.editor.editorType.web#editorName#onEditorCreate

以下の表に、各エディターのeditorType、変数、およびeditorNameを示します。

editorType変数editorName
alloyeditoralloyEditoralloyeditor
  alloyeditor_bbcode
  alloyeditor_creole
ckeditorckEditorckeditor
  ckeditor_bbcode
  ckeditor_creole
tinymcetinyMCEEditortinymce
  tinymce_simple

次の例では、ユーザがコンテンツをCKEditorに貼り付けると警告が表示されます。

*DynamicInclude Javaクラス:

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

@Override
public void include(
HttpServletRequest request, HttpServletResponse response,
String key)
throws IOException {

Bundle bundle = _bundleContext.getBundle();

URL entryURL = bundle.getEntry(
"/META-INF/resources/ckeditor/extension/ckeditor_alert.js");

StreamUtil.transfer(
entryURL.openStream(), response.getOutputStream(), false);
}

@Override
public void register(
DynamicInclude.DynamicIncludeRegistry dynamicIncludeRegistry) {

dynamicIncludeRegistry.register(
"com.liferay.frontend.editor.ckeditor.web#ckeditor#onEditorCreate");
}

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

private BundleContext _bundleContext;

}

JavaScriptの例:

// ckEditor variable is already available in the execution context
ckEditor.on(
'paste',
function(event) {
event.stop();

alert('Please, do not paste code here!');
}
);

これで、WYSIWYGエディターの動的インクルードの使用方法がわかりました。

関連トピック

Adding New Behavior to an Editor

Bottom JSP Dynamic Includes

Top Head JSP Dynamic Includes

Top JS Dynamic Include

« 動的インクルードTop Head JSP動的インクルード »
この記事は役に立ちましたか?
0人中0人がこの記事が役に立ったと言っています