Skip to main content
GameDev.net gamedev.net
🔒 Locked

CKEEDITOR Markdown plugin test

Started by fastcall22 Aug 18, 2017 at 7:08 PM 1 replies 1.4k views
Original Post
fastcall22
fastcall22

Markdown Test

The quick brown fox jumps over the Lazy Googled.

Markdown plugin fix

The plugin is available to the CKEditor here, but a few bugs cause it from working properly.

First, break at applications/core/interface/ckeditor/ckeditor/plugins/markdown/plugin.js:48, switch the editor to markdown mode (see below), then apply the fix:


/* jshint esversion:6 */
// Break at applications/core/interface/ckeditor/ckeditor/plugins/markdown/plugin.js:48
// then:

// fix addClass not supporting multiple styles
(t => {
  if ( t.addClass._hacked ) {
    return;
  }

  var _old_addClass = t.addClass;
  t.addClass = str =>
    str.split(' ').forEach(_old_addClass.bind(t));
  t.addClass._hacked = true;
})(textarea);

// pacify markdown plugin expecting maximize command
['commands','maximize','modes'].reduce( (obj, k) => {
  obj[k] = obj[k]||{};
  return obj[k];
}, editor);

// pacify CKE expecting enable/disable methods on the maximize command
(maximize => {
  maximize.enable = maximize.disable = function(){};
})(editor.command.maximize);

Then, enable markdown (where’s the button?)

Object.values(CKEDITOR.instances).forEach((editor) => editor.setMode('markdown'))

And finally,

Object.values(CKEDITOR.instances).forEach((editor) => editor.setMode('wysiwyg'))


Observations:

Cannot use IPBoard widgets, until after the markdown is converted to HTML. Markdown first, convert to HTML, then insert quote selections.

Generated HTML is raw and does not get promoted through IPBoard filters— had to reinsert code using the code button.

Codemirror is a good browser based text editor, but Firefox has a dumb bug for word–wrapping textareas, where the text cursor spans multiple lines. Very annoying.

fastcall22
fastcall22
3 minutes ago, fastcall22 said:

Observations:

Alternatively, there’s the source mode that preserves IPBoard existing markup.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.