<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0">
<channel>
	<title>CodyHouse</title>
	<atom:link href="https://codyhouse.co/feed.xml" rel="self" type="application/rss+xml"/>
	<link>https://codyhouse.co</link>
	<description>CodyHouse is an arsenal of production-ready components and tools that empower web designers to craft digital experiences faster and better.</description>
	<lastBuildDate>Mon, 21 Mar 2022 15:22:32 +0000</lastBuildDate>
	<language>en-US</language>
  <item>
    <title>Component - Markdown Editor</title>
    <link>https://codyhouse.co/ds/components/app/markdown-editor</link>
    <pubDate>Tue, 15 Mar 2022 15:14:55 +0100</pubDate>
    <guid>https://codyhouse.co/ds/components/app/markdown-editor</guid>
    <description><![CDATA[A minimal editor to create markdown content.<img src="https://codyhouse.co/web/assets/img/ds/components/preview/markdown-editor.svg" alt="Markdown Editor"><div class="article text-component margin-bottom-md"><h2>Download + Demo</h2><ul><li><a href="https://codyhouse.co/ds/components/app/markdown-editor">View Demo</a></li><li><a href="https://codyhouse.co/ds/components/info/markdown-editor">Download Component</a></li></ul></div><h2>How to</h2>
<p>Use this component to write markdown content.</p>
<p>You can initialize the editor using the <code>MdEditor</code> object:</p>
<pre class="language-javascript"><code class="javascript hljs js-hljs">var mdEditor = document.getElementsByClassName('md-editor')[0]; // your markdown editor element
new MdEditor(mdEditor);</code></pre>
<p>Note that in the markdown-editor.js, we do not initialize the <code>MdEditor</code> object.&nbsp;</p>
<h3 id="actions">Editor Actions <a class="heading-link js-smooth-scroll" href="#actions">#</a></h3>
<p>By default, the editor comes with the following list of actions:</p>
<pre class="language-javascript"><code class="javascript hljs js-hljs">MdEditor.defaults = [
    {
      action: 'heading',
      content: '###content',
      newLine: false
    },
    {
      action: 'code',
      content: '`content`',
      newLine: false
    },
    {
      action: 'link',
      content: '[content](url)',
      newLine: false
    },
    {
      action: 'blockquote',
      content: '&gt; content',
      newLine: true
    },
    {
      action: 'bold',
      content: '**content**',
      newLine: false
    },
    {
      action: 'italic',
      content: '_content_',
      newLine: false
    },
    {
      action: 'uList',
      content: '- Item 1\n- Item 2\n- Item 3',
      newLine: true
    },
    {
      action: 'oList',
      content: '1. Item 1\n2. Item 2\n3. Item 3',
      newLine: true
    },
    {
      action: 'tList',
      content: '- [ ] Item 1\n- [x] Item 2\n- [ ] Item 3',
      newLine: true
    }
  ];</code></pre>
<p>Each element of the list is composed of:</p>
<ul>
<li><code>action</code>: this is equal to the <code>data-md-action</code> attribute of the <code>.md-editor__btn</code> button element;</li>
<li><code>content</code>: this is the content to insert in the textarea; the keyword 'content' will be replaced by the selected text (if any);</li>
<li><code>newLine</code>: true if a new line needs to be inserted before the new content.</li>
</ul>
<p>You can create your custom actions list and pass it to the <code>MdEditor</code> object during initialization (this will replace the default actions):</p>
<pre class="language-javascript"><code class="javascript hljs js-hljs">var customActions = [
  {
    action: 'heading',
    content: '###content',
    newLine: false
  },
  {
    action: 'code',
    content: '`content`',
    newLine: false
  },
  {
    action: 'link',
    content: '[content](url)',
    newLine: false
  }
];

new MdEditor(mdEditor, customActions);</code></pre>]]></description>
  </item>
</channel>
</rss>
