cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              /** @jsx h */
const { diff, patch, create } = virtualDom;
const { createStore } = Redux;

function h(type, props) {
  const hasChildren = arguments.length > 2;
  const isComponent = typeof type == 'function';

  let children = [];
  if (arguments[2] instanceof Array) {
    children = arguments[2];
  } else {
    children = [].slice.call(arguments, 2);
  }

  if (isComponent) {
    return type(props, children);
  } else {
    return virtualDom.h(type, props, children);
  }
};

const initState = {
  text: ''
};

// Redux Store
// ===========
// Each of these methods should dispatch an action to
// the Redux store.
const store = createStore((state = initState, action) => {
  switch (action.type) {
    case 'UPDATE_TEXT':
      return {
        text: action.payload
      };
    default:
      return state;
  }
});

// Action Creators
// ===============
// Each of these methods should dispatch an action to
// the Redux store.
const actions = {
  updateText(text) {
    store.dispatch({
      type: 'UPDATE_TEXT',
      payload: text
    });
  }
}

// Markdown Component
// ==================
// This component accepts a string to be turned into
// markdown as an argument and renders it as markup
// inside a div.
function Markdown({ text='' }) {
  return <div innerHTML={marked(text)} />
}

// Editor Component
// ================
// This component accepts an onEdit prop which it will
// call with the current text inside the editor each
// time it is changed.
function Editor({ onEdit, text }) {
  const update = e => onEdit(e.target.value);

  return <textarea oninput={update} />;
}

function MarkdownEditor({ state }) {
  return (
    <main>
      <section>
        <label>Markdown</label>
        <hr />
        <Editor onEdit={actions.updateText} />
      </section>
      <section>
        <label>Preview</label>
        <hr />
        <Markdown text={state.text} />
      </section>
    </main>
  );
}

let tree = <MarkdownEditor state={store.getState()} />;
let root = create(tree);

store.subscribe(function() {
  let newTree = <MarkdownEditor state={store.getState()} />;
  let patches = diff(tree, newTree);
  root = patch(root, patches);
  tree = newTree;
});

document.getElementById('app')
  .appendChild(root);
        
            
          
!
999px
Loading ..................

Console