Ayudh
Ayudh

Reputation: 1763

how to add function that adds css style/class to text in simpleMDE?

I cant do what is stated here: How to add a custom Markdown function to SimpleMDE? which is:

function drawRedText(editor) {
var cm = editor.codemirror;
var output = '';
var selectedText = cm.getSelection();
var text = selectedText || 'placeholder';

output = '<p class="center">' + text + '</p>'; //.center is defined as {text-align: center;}
cm.replaceSelection(output);
}

As this will not work if I do it on '#h1' which is a heading.

Basically, I am trying to create a function that aligns the selection to the center.

Is there any way to add the styling to the selected/highlighted element?

Upvotes: 1

Views: 716

Answers (0)

Related Questions