mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
142 lines
2.9 KiB
HTML
Executable File
142 lines
2.9 KiB
HTML
Executable File
<html>
|
|
<head>
|
|
<style>
|
|
|
|
:root {
|
|
font-family: sans-serif;
|
|
font-size: 5mm;
|
|
}
|
|
|
|
.editor [tabindex] {
|
|
position: relative;
|
|
}
|
|
.editor div [tabindex] {
|
|
margin-left: 2em;
|
|
}
|
|
.editor [tabindex]>span,
|
|
.editor [tabindex]>textarea {
|
|
--padding: 0.2em;
|
|
|
|
display: block;
|
|
width: 100%;
|
|
padding: var(--padding);
|
|
margin: 0;
|
|
|
|
font-family: sans-serif;
|
|
font-size: 5mm;
|
|
white-space: pre;
|
|
|
|
outline: none;
|
|
border: none;
|
|
}
|
|
.editor [tabindex]>textarea {
|
|
height: calc(2 * var(--padding) + 1em);
|
|
overflow: hidden;
|
|
resize: none;
|
|
}
|
|
|
|
/* show/hide node's view/code... */
|
|
.editor [tabindex]>span+textarea:not(:focus),
|
|
/* XXX not sure how to do this without :has(..)... */
|
|
.editor [tabindex]:has(>span+textarea:focus)>span:has(+textarea),
|
|
.editor [tabindex]:focus>span+textarea {
|
|
position: absolute;
|
|
opacity: 0;
|
|
top: 0;
|
|
}
|
|
|
|
.editor div[collapsed] {
|
|
border-bottom: solid 1px silver;
|
|
}
|
|
.editor div[collapsed] div {
|
|
display: none;
|
|
}
|
|
|
|
.editor div:focus {
|
|
/*outline: solid 0.2em silver;*/
|
|
outline: none;
|
|
}
|
|
.editor div:focus>span,
|
|
.editor div:focus>textarea {
|
|
background: silver;
|
|
}
|
|
|
|
</style>
|
|
<script src="generic.js"></script>
|
|
<script src="editor.js"></script>
|
|
<script>
|
|
|
|
var setup = function(){
|
|
window.editor = {
|
|
__proto__: Outline,
|
|
}.setup(
|
|
document.querySelector('.editor'))
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body onload="setup()">
|
|
<div class="editor">
|
|
<div tabindex=0>
|
|
<span><i>root</i></span><textarea></textarea>
|
|
<div tabindex=0 collapsed>
|
|
<span>A</span><textarea></textarea>
|
|
<div tabindex=0><span>a</span><textarea></textarea>
|
|
</div>
|
|
<div tabindex=0><span>b</span><textarea></textarea>
|
|
</div>
|
|
<div tabindex=0><span>c</span><textarea></textarea>
|
|
</div>
|
|
</div>
|
|
<div tabindex=0><span>B</span><textarea></textarea>
|
|
<div tabindex=0><span>d</span><textarea></textarea>
|
|
</div>
|
|
<div tabindex=0><span>e</span><textarea></textarea>
|
|
</div>
|
|
</div>
|
|
<div tabindex=0><span>C</span><textarea></textarea>
|
|
<div tabindex=0><span>This is a line of text</span><textarea></textarea>
|
|
</div>
|
|
<div tabindex=0><span>This is a set
|
|
text lines</span><textarea></textarea>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<hr>
|
|
|
|
<pre>
|
|
TODO:
|
|
- mouse controls
|
|
- touch controls
|
|
- <s>navigation</s>
|
|
- <s>expand/collapse subtree</s>
|
|
- <s>shift subtree up/down</s>
|
|
- <s>create node</s>
|
|
- <s>edit node</s>
|
|
- undo delete node
|
|
- copy/paste nodes/trees
|
|
- shifting nodes up/down
|
|
- multiple node selection
|
|
- <s>serialize</s>/deserialize
|
|
- add optional styling to nodes
|
|
|
|
Controls:
|
|
up - focus node above
|
|
down - focus node below
|
|
left - focus parent node
|
|
right - focus first child node
|
|
tab - indent node
|
|
s-tab - deindent node
|
|
s-left - collapse node
|
|
s-right - expand node
|
|
enter - normal mode: edit node
|
|
- edit mode: create node below
|
|
esc - exit edit mode
|
|
</pre>
|
|
|
|
</body>
|
|
</html>
|
|
<!-- vim:set ts=4 sw=4 : -->
|