forked from klieret/verzettler
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
The load works but the save is wip
- Loading branch information
Showing
3 changed files
with
94 additions
and
1 deletion.
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
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,31 @@ | ||
const addScript = (path, callback) => { | ||
const scriptElement = document.createElement('script') | ||
scriptElement.src = path | ||
scriptElement.async = true | ||
document.head.appendChild(scriptElement) | ||
scriptElement.onload = () => { | ||
callback() | ||
} | ||
} | ||
|
||
const addStyle = (url) => { | ||
const styleElement = document.createElement('link') | ||
styleElement.rel = 'stylesheet' | ||
styleElement.type = 'text/css' | ||
styleElement.href = url | ||
document.getElementsByTagName('head')[0].appendChild(styleElement) | ||
} | ||
|
||
addStyle('https://cdn.jsdelivr.net/npm/vditor@3.5.5/dist/index.css') | ||
document.addEventListener('DOMContentLoaded', function () { | ||
var hm = document.createElement('script') | ||
var s = document.getElementsByTagName('script')[0] | ||
s.parentNode.insertBefore(hm, s) | ||
if (document.getElementById('vdit')) { | ||
addScript('https://cdn.jsdelivr.net/npm/vditor@3.5.5/dist/index.min.js', | ||
() => { | ||
vditorScript() | ||
}) | ||
} | ||
}) | ||
|
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,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"/> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"/> | ||
<title>Verzettel editor</title> | ||
<meta http-equiv="Window-target" content="_top"/> | ||
<script src='/static/js/edit.js' defer></script> | ||
</head> | ||
<body> | ||
<p>NAVBAR</p> | ||
</p> | ||
|
||
<div class="wrapper"> | ||
<div id="vditor"></div> | ||
<div id="vdit"></div> | ||
<button class="btn btn--small"onclick="document.getElementById('vditor').value=vditor.getValue();sendContent(this, vditor.getSelection())";'> Save</button> | ||
</div> | ||
|
||
<script> | ||
const content = {{value |tojson}}; | ||
const id = {{id|tojson}}; | ||
|
||
let vditor | ||
vditorScript = () => { | ||
vditor = new Vditor('vditor', { height: 360, | ||
width: 800, | ||
cache: {enable: false}, | ||
value: content, | ||
lang: 'en_US', | ||
mode: 'ir', | ||
preview: {math:{engine:'MathJax'}}})}; | ||
|
||
|
||
const sendContent= (it)=> { | ||
// alert(vditor.getValue()) | ||
fetch(id, {method:"POST", body: JSON.stringify({content: vditor.getValue()})})} | ||
|
||
</script> | ||
<!-- mode: 'wysiwyg'}) | ||
https://b3log.org/vditor/demo/method-get.html | ||
https://stackoverflow.com/questions/6396101/pure-javascript-send-post-data-without-a-form | ||
view-source:https://b3log.org/vditor/demo/advanced-toolbar.html | ||
https://b3log.org/vditor/demo/advanced-upload.html | ||
mode: 'ir'}) | ||
mode: 'sv',preview:{mode:'editor'}}) | ||
mode: 'sv',preview:{mode:'both'}})"> double panel --> | ||
</body> | ||
</html> |