vim.md

simple vi markdown editor https://github.com/joseamarin/vim.MD joseamarin.github.io/vim.md/
git clone http://git.hanabi.in/repos/vim.md.git
Log | Files | Refs | README

commit 28f720cde4052aee3809e176ddb27dc9f9076437
parent 09b36f3f5858ac0695c8c108f676b5cd913bfd3b
Author:  <josemarinemail@gmail.com>
Date:   Thu, 12 Jul 2018 17:55:16 -0400

implemented working copy feature need to complete export

Diffstat:
Mindex.html | 5+++--
Mjavascript/main.js | 28++++++++++++++++++++++------
2 files changed, 25 insertions(+), 8 deletions(-)

diff --git a/index.html b/index.html @@ -35,7 +35,7 @@ </span> </a> </p> - <p class="control"> + <p class="control js-export"> <a class="button is-success" href="#"> <span class="icon"> <i class="fas fa-share-square"></i> @@ -50,7 +50,8 @@ </nav> <div class="book-wrapper"> <div class="book-wrapper-inner"> - <div class="book-col--40 js-input"></div> + <div class="book-col--40 js-input"> + </div> <div class="book-col--60"> <div class="book-content"> <div class="main-content js-content" style="padding-bottom: 100px;"></div> diff --git a/javascript/main.js b/javascript/main.js @@ -43,12 +43,28 @@ }); } - const copy = () => { - const copyText = document.querySelector(".js-copy"); - copyText.select(editor.getValue()); - document.execCommand("copy"); - } + document.querySelector('.js-copy').addEventListener('click', event => { + const textarea = document.createElement('textarea'); + textarea.innerHTML = window.localStorage.getItem('markdown'); + const successful = document.execCommand('copy'); + const textToCopy = document.querySelector('textarea'); + document.querySelector('.js-input').appendChild(textarea); + textarea.focus(); + textarea.select(); - document.querySelector(".js-copy").addEventListener("click", copy); + try { + const successful = document.execCommand('copy'); + } + catch (err) { + alert('Copy not supported'); + } + finally { + document.querySelector('.js-input').removeChild(textarea); + } + }); + + document.querySelector('.js-export').addEventListener('click', event => { + window.open('about:blank', '_blank'); + }); })();