How to use the mobiledoc-kit/renderers/mobiledoc/0-3.render function in mobiledoc-kit

To help you get started, we’ve selected a few mobiledoc-kit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bustle / mobiledoc-kit / tests / helpers / mobiledoc.js View on Github external
function build(treeFn, version) {
  let post = PostAbstractHelpers.build(treeFn);
  switch (version) {
    case MOBILEDOC_VERSION_0_2:
      return MobiledocRenderer_0_2.render(post);
    case MOBILEDOC_VERSION_0_3:
      return MobiledocRenderer_0_3.render(post);
    case MOBILEDOC_VERSION_0_3_1:
      return MobiledocRenderer_0_3_1.render(post);
    case MOBILEDOC_VERSION_0_3_2:
      return MobiledocRenderer_0_3_2.render(post);
    case undefined:
    case null:
      return mobiledocRenderers.render(post);
    default:
      throw new Error(`Unknown version of mobiledoc renderer requested: ${version}`);
  }
}
github bustle / mobiledoc-kit / tests / helpers / editor.js View on Github external
function buildFromText(texts, editorOptions={}) {
  let renderElement = editorOptions.element;
  delete editorOptions.element;

  let {post, range} = PostAbstractHelpers.buildFromText(texts);
  let mobiledoc = MobiledocRenderer.render(post);
  editorOptions.mobiledoc = mobiledoc;
  let editor = new Editor(editorOptions);
  if (renderElement) {
    editor.render(renderElement);
    range = retargetRange(range, editor.post);
    editor.selectRange(range);
  }
  return editor;
}