Public
HTTP (deprecated)
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Readme

Quill.js WYSIWYG

Basic WYSIWYG rich text editor, using quill.js.

Press the "Get HTML" button to show the HTML in an alert window.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
export default async function(req: Request) {
if (req.method === "POST") {
const name = (await req.formData()).get("name");
return new Response("Hello World");
}
return new Response(
`<html>
<head>
<title>Title</title>
<style>{"html { font-family: sans-serif; }"}</style>
<script src="https://unpkg.com/htmx.org@1.9.9"></script>
<script>htmx.logAll()</script>
<link href="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.snow.css" rel="stylesheet" />
<script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"></script>
</head>
<body>
<div>
<button hx-on:click="alert(quill.getSemanticHTML())">Get HTML</button>
</div>
<br />
<div id="editor" hx-on:click="console.log(quill.getSemanticHTML())">
<div id="editor-container"></div>
<p>Hello World!</p>
<p>
Some initial <strong>bold</strong> text
</p>
<p>
<br />
</p>
</div>
<script>
const toolbarOptions = [
["bold", "italic", "underline", "strike"], // toggled buttons
["blockquote", "code-block"],
["link", "image", "video", "formula"],
[{ "header": 1 }, { "header": 2 }], // custom button values
[{ "list": "ordered" }, { "list": "bullet" }, { "list": "check" }],
[{ "script": "sub" }, { "script": "super" }], // superscript/subscript
[{ "indent": "-1" }, { "indent": "+1" }], // outdent/indent
[{ "size": ["small", false, "large", "huge"] }], // custom dropdown
[{ "header": [1, 2, 3, 4, 5, 6, false] }],
[{ "color": [] }, { "background": [] }], // dropdown with defaults from theme
[{ "font": [] }],
[{ "align": [] }],
["clean"], // remove formatting button
];
let options = {
debug: 'info',
modules: {
toolbar: toolbarOptions,
},
theme: 'snow',
};
let quill = new Quill('#editor', options)
const container = quill.addContainer('ql-custom');
</script>
</body>
</html>`,
{
headers: {
"Content-Type": "text/html; charset=utf-8",
},
},
);
}
rayman-purplebee.web.val.run
April 29, 2024