Skip to content

Commit

Permalink
Added "Preview" button and listener
Browse files Browse the repository at this point in the history
Added related output/CSS rules
  • Loading branch information
nuxy committed Apr 2, 2024
1 parent 56b24de commit a23d599
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 4 deletions.
28 changes: 27 additions & 1 deletion demo/css/demo.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
body {
font-family: sans-serif;
margin: 2px;
}

form {
font-family: sans-serif;
margin: 10% auto 0 auto;
width: 380px;
}
Expand Down Expand Up @@ -45,3 +45,29 @@ form textarea {
form .textmarked {
margin: 5px 0;
}

#output {
border-top: 1px solid #bbb;
height: 400px;
margin-top: 50px;
padding: 20px 10px 10px 10px;
}

#output * {
margin: 0;
padding: 0;
}

#output blockquote {
background-color: #eee;
color: #555;
border-left: 2px solid #999;
font-style: italic;
margin: 10px 5px;
padding: 10px;
}

#output code {
background-color: #eee;
color: #555;
}
20 changes: 17 additions & 3 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,22 @@

var textarea = document.getElementById('comments');

textMarked(textarea, settings).focus();
var editor = textMarked(textarea, settings);
editor.focus();

var button = document.getElementById('toggle-button');
var output = document.getElementById('output');

button.addEventListener('click', event => {
var previewButton = document.getElementById('preview-button');

previewButton.addEventListener('click', event => {
event.preventDefault();

output.innerHTML = editor.markup();
});

var toggleButton = document.getElementById('toggle-button');

toggleButton.addEventListener('click', event => {
event.preventDefault();

var field1 = document.querySelector('#comments');
Expand All @@ -59,6 +70,7 @@
<form>
<fieldset>
<legend>
<button id="preview-button">Preview</button>
<button id="toggle-button">Toggle</button>
</legend>

Expand All @@ -71,5 +83,7 @@

<input type="Reset" />
</form>

<div id="output"></div>
</body>
</html>

0 comments on commit a23d599

Please sign in to comment.