Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: add example for setting content programmatically (#250)
- Loading branch information
1 parent
33bc2d5
commit 1916ff1
Showing
1 changed file
with
83 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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> |