antonmedv/codejar

Toolbar for markup languages?

erickilisboa opened this issue · 3 comments

It would be a boon for users of markdown and textile (even more because it does not depend on a specific syntax highlight) a toolbar for these languages. Or for one of them, but easily modified for others. The options currently available are often quite heavy and cannot be used with external syntax highlighting.

I think a such toolbar can be easily implemented. But it out of the scope of the current CodeJar agenda. CodeJar trying to be a language-agnostic editor.

I am trying to create a simple toolbar, however I have a problem. The undo feature does not work for the content inserted by the toolbar.

Is there something wrong with this?

function wrap(tag) {
  jar.recordHistory();

  sel = window.getSelection();
  if (sel.rangeCount) {
    range = sel.getRangeAt(0);
    range.insertNode(document.createTextNode(tag));
    range.collapse();
    range.insertNode(document.createTextNode(tag));
  }

  jar.updateCode(jar.toString());
}

Now there is a method: recordHistory.