split out css + minor fix...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-09-29 02:47:07 +03:00
parent 45d8ef11d3
commit 94ef144c0f
3 changed files with 65 additions and 63 deletions

View File

@ -0,0 +1,61 @@
: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%;
/* XXX this is a tiny bit off and using textarea's height here is off too... */
min-height: 1em;
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;
}

View File

@ -314,10 +314,10 @@ var Outline = {
// indent...
Tab: function(evt){
evt.preventDefault()
var editable = this.get('editable')
var edited = this.get('edited')
var node = this.indent(!evt.shiftKey)
;(editable ?
editable
;(edited ?
edited
: node)?.focus() },
// edit mode...

View File

@ -1,67 +1,8 @@
<html>
<head>
<link href="editor.css" rel="stylesheet"/>
<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%;
/* XXX this is a tiny bit off and using textarea's height here is off too... */
min-height: 1em;
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>