liferay/liferay-ckeditor

CodeMirror fails to load when "Expose Global" is enabled

kevhlee opened this issue · 1 comments

In Liferay DXP, the "Source mode" in CKEditor no longer functions when "Expose Global" is enabled. This issue is that the CodeMirror plugin does not properly load. Please see PTR-2064 for more context.

JS_Error

In liferay-ckeditor/plugins/codemirror/vendors/vendors.js, we have the following AMD-related code (unminified for readability):

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  typeof define === 'function' && define.amd ? define(factory) :
  (global = global || self, global.CodeMirror = factory());
}(this, (function () { 'use strict';

One solution would be adding the following to the logic:

(function (global, factory) {
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
  false && typeof define === 'function' && define.amd ? define(factory) :
  (global = global || self, global.CodeMirror = factory());
}(this, (function () { 'use strict';

By adding false to the condition, we would prevent CodeMirror from being loaded using AMD. However, since liferay-ckeditor/plugins/codemirror/vendors/vendors.js is auto-generated, we would need to ensure that the change does not get overwritten. I'm not entirely sure how to apply this change, which is why I have not created a PR yet.

If this is not the ideal solution, please feel free to share other solutions. Let me know if you have any questions/thoughts.

cc: @julien, @carloslancha, @wincent

Fixed in #141