Skip to content

Commit

Permalink
docs: add example for setting content programmatically (#250)
Browse files Browse the repository at this point in the history
  • Loading branch information
1c7 authored and kyuwoo-choi committed Jul 9, 2018
1 parent 33bc2d5 commit 1916ff1
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions examples/example18-set-content-programmatically.html
@@ -0,0 +1,83 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title>18. set content programmatically</title>
<script src="../lib/jquery/dist/jquery.js"></script>
<script src="../lib/markdown-it/dist/markdown-it.js"></script>
<script src="../lib/to-mark/dist/to-mark.js"></script>
<script src="../lib/tui-code-snippet/dist/tui-code-snippet.js"></script>
<script src="../lib/tui-color-picker/dist/tui-color-picker.js"></script>
<script src="../lib/codemirror/lib/codemirror.js"></script>
<script src="../lib/highlightjs/highlight.pack.js"></script>
<script src="../lib/squire-rte/build/squire-raw.js"></script>
<link rel="stylesheet" href="../lib/codemirror/lib/codemirror.css">
<link rel="stylesheet" href="../lib/highlightjs/styles/github.css">
<link rel="stylesheet" href="./explain.css">
</head>
<body>
<div class="explain">
Learn how to set content programmatically
</div>
<div class="code-html">
<script src="../lib/plantuml-encoder/dist/plantuml-encoder.js"></script>
<script src="../lib/raphael/raphael.js"></script>
<script src="../lib/tui-chart/dist/tui-chart.js"></script>
<script src="../dist/tui-editor-Editor-all.js"></script>
<link rel="stylesheet" href="../dist/tui-editor.css">
<link rel="stylesheet" href="../dist/tui-editor-contents.css">
<link rel="stylesheet" href="../lib/tui-color-picker/dist/tui-color-picker.css">
<link rel="stylesheet" href="../lib/tui-chart/dist/tui-chart.css">
<button id='mybutton'>Click me to set content programmatically</button>
<div id="editSection"></div>
<script class="code-js">
var content = `use "editor.setValue" to set content programmatically`;
var editor = new tui.Editor({
el: document.querySelector('#editSection'),
previewStyle: 'vertical',
height: '400px',
initialEditType: 'markdown',
initialValue: content
});

var content2 = [
'![image](https://cloud.githubusercontent.com/assets/389021/16107646/9729e556-33d8-11e6-933f-5b09fa3a53bb.png)',
'# Heading 1',
'## Heading 2',
'### Heading 3',
'#### Heading 4',
'##### Heading 5',
'###### Heading 6',
' code block',
'```js',
'console.log("fenced code block");',
'```',
'<pre>**HTML block**</pre>',
'* list',
' * list indented',
'1. ordered',
'2. list',
' 1. ordered list',
' 2. indented',
'',
'- [ ] task',
'- [x] list completed',
'',
'[link](https://nhnent.github.io/tui.editor/)',
'> block quote',
'---',
'horizontal line',
'***',
'`code`, *italic*, **bold**, ~~strikethrough~~, <span style="color:#e11d21">Red color</span>',
'|table|head|',
'|---|---|',
'|table|body|'
].join('\n');

var el = document.querySelector('#mybutton');
el.addEventListener('click', function(){
editor.setValue(content2)
})
</script>
</body>
</html>

0 comments on commit 1916ff1

Please sign in to comment.