diff --git a/static/css/main.css b/static/css/main.css
index 52dca9e..e853491 100644
--- a/static/css/main.css
+++ b/static/css/main.css
@@ -145,18 +145,21 @@ header .menu {
.node-content {
justify-self: center;
padding: 16px 32px;
- white-space: pre-wrap;
+ word-wrap: break-word;
+ font-family: monospace;
font-size: 0.85em;
color: #333;
width: 100ex;
+ resize: none;
+ border: none;
+ outline: none;
}
.node-content[contenteditable] {
outline: 0px solid transparent;
}
-.node-content:empty {
- background: #ddd;
+.node-content:invalid {
+ border-bottom: 1px solid #eee;
border-radius: 8px;
- height: 48px;
}
.tree {
padding: 16px;
diff --git a/static/index.html b/static/index.html
index 5c92d11..3ee9dc4 100644
--- a/static/index.html
+++ b/static/index.html
@@ -5,8 +5,6 @@
-
-
+
+
diff --git a/static/js/app.mjs b/static/js/app.mjs
index 310190c..0536f22 100644
--- a/static/js/app.mjs
+++ b/static/js/app.mjs
@@ -9,7 +9,7 @@ const html = htm.bind(h)
class App extends Component {
constructor() {//{{{
super()
- this.websocket_uri = `wss://notes.ahall.se/ws`
+ this.websocket_uri = `ws://localhost:1371/ws`
this.websocket = null
this.websocket_int_ping = null
this.websocket_int_reconnect = null
diff --git a/static/js/node.mjs b/static/js/node.mjs
index 9287eaa..a12c788 100644
--- a/static/js/node.mjs
+++ b/static/js/node.mjs
@@ -64,16 +64,18 @@ export class NodeUI extends Component {
${crumbs}
${children.length > 0 ? html`
${children}
` : html``}
-
this.retrieveTree()} style="color: #000">
-
Start
- ${treeHTML}
-
${node.ID > 0 ? html`
${node.Name}
<${NodeContent} key=${node.ID} content=${node.Content} ref=${this.nodeContent} />
` : html``}
`
+ /*
+
this.retrieveTree()} style="color: #000">
+
Start
+ ${treeHTML}
+
+ */
}//}}}
componentDidMount() {//{{{
let urlParams = new URLSearchParams(window.location.search)
@@ -118,7 +120,11 @@ export class NodeUI extends Component {
.catch(this.props.app.responseError)
}//}}}
saveNode() {//{{{
- let content = this.nodeContent.current.contentDiv.current.innerText
+ let content = this.nodeContent.current.contentDiv.current.value
+ content = content
+ .replaceAll("\r", "")
+ .replaceAll("
", "")
+
this.props.app.request('/node/update', {
NodeID: this.node.value.ID,
Content: content,
@@ -178,7 +184,24 @@ class NodeContent extends Component {
}
}//}}}
render({ content }) {//{{{
- return html`
window._app.current.nodeModified.value = true}>${content}
`
+ return html`
+
+ `
+ }//}}}
+ componentDidMount() {//{{{
+ this.resize()
+ }//}}}
+ componentDidUpdate() {//{{{
+ this.resize()
+ }//}}}
+ contentChanged() {//{{{
+ window._app.current.nodeModified.value = true
+ this.resize()
+ }//}}}
+ resize() {//{{{
+ let textarea = this.contentDiv.current;
+ textarea.style.height = "auto";
+ textarea.style.height = textarea.scrollHeight + 16 + "px";
}//}}}
}
@@ -193,7 +216,6 @@ class Node {
this.Children = []
this.Crumbs = []
}//}}}
-
retrieve(callback) {//{{{
this.app.request('/node/retrieve', { ID: this.ID })
.then(res=>{
diff --git a/static/less/main.less b/static/less/main.less
index 4e25746..9896725 100644
--- a/static/less/main.less
+++ b/static/less/main.less
@@ -172,19 +172,23 @@ header {
.node-content {
justify-self: center;
padding: 16px 32px;
- white-space: pre-wrap;
+ word-wrap: break-word;
+ font-family: monospace;
font-size: 0.85em;
color: #333;
width: 100ex;
+ resize: none;
+ border: none;
+ outline: none;
&[contenteditable] {
outline: 0px solid transparent;
}
- &:empty {
- background: #ddd;
+ &:invalid {
+ //background: #eee;
+ border-bottom: 1px solid #eee;
border-radius: 8px;
- height: 48px;
}
}