Compare commits

..

No commits in common. "53ad5723697603a0d51eb729f01490f95c164d09" and "dcc4ff1aeedd13f8f422d0cb06f0857e8d886c3b" have entirely different histories.

3 changed files with 60 additions and 117 deletions

View File

@ -28,6 +28,8 @@
/*text-size-adjust: none;*/ /*text-size-adjust: none;*/
text-size-adjust: 150%; text-size-adjust: 150%;
} }
.editor { .editor {
@ -142,18 +144,11 @@ editor .outline .block:focus {
} }
.editor .outline .block.focused:not(:focus)>.text { .editor .outline .block.focused:not(:focus)>.text {
background: rgba(0,0,0,0.01); background: rgba(0,0,0,0.01);
border-bottom: solid 2px rgba(0,0,0,0.03);
} }
/* collapsed block... */ .editor .outline div[collapsed] {
.editor .outline .block[collapsed] {
border-bottom: solid 1px silver; border-bottom: solid 1px silver;
} }
/* hide children... */
.editor .outline .block[collapsed]>.children {
display: none;
}
/* click/tap zones for expand button... */ /* click/tap zones for expand button... */
.editor .outline .block>.view:before, .editor .outline .block>.view:before,
@ -205,6 +200,11 @@ editor .outline .block:focus {
content: "●"; content: "●";
} }
/* collapse -- hide children... */
.editor .outline .block[collapsed] .block {
display: none;
}
/* XXX are we selecting subtrees or blocks??? */ /* XXX are we selecting subtrees or blocks??? */
.editor .outline [selected] { .editor .outline [selected] {
background: silver; background: silver;
@ -233,9 +233,7 @@ editor .outline .block:focus {
/********************************************************** Styles ***/ /********************************************************** Styles ***/
/* Headings... */
/*------------------------------------------------------ Headings ---*/
.editor .outline .heading-1, .editor .outline .heading-1,
.editor .outline .heading-2, .editor .outline .heading-2,
.editor .outline .heading-3, .editor .outline .heading-3,
@ -278,8 +276,7 @@ editor .outline .block:focus {
} }
/*--------------------------------------------------------- Quote ---*/ /* Quote... */
.editor .outline .quote>.text { .editor .outline .quote>.text {
--indent: 1rem; --indent: 1rem;
--margin: 0.7rem; --margin: 0.7rem;
@ -301,8 +298,8 @@ editor .outline .block:focus {
} }
/*---------------------------------------------------------- List ---*/ /* List... */
/* XXX needs to be in the middle of the first .view but with universal size... */
.editor .outline .list-item>.view:before, .editor .outline .list-item>.view:before,
.editor .outline .list>.children>.block>.view:not(:empty):before { .editor .outline .list>.children>.block>.view:not(:empty):before {
content: "◼"; content: "◼";
@ -328,15 +325,16 @@ editor .outline .block:focus {
} }
/*------------------------------------------------ Numbered lists ---*/ /* List... */
/* XXX nested lists are broken -- seems that I need a container for the children... */
.editor .outline .numbered-list>.children {
counter-reset: numbered-list;
}
.editor .outline .numbered-list>.children>.block>.view:not(:empty):before { .editor .outline .numbered-list>.children>.block>.view:not(:empty):before {
counter-increment: numbered-list; counter-increment: numbered-list;
content: counter(numbered-list) "."; content: counter(numbered-list) ".";
color: gray; color: gray;
} }
/* numbered lists... */
.editor .outline .editor .outline
.numbered-list>.children .numbered-list>.children
>.numbered-list>.children>.block>.view:not(:empty):before { >.numbered-list>.children>.block>.view:not(:empty):before {
@ -363,8 +361,7 @@ editor .outline .block:focus {
} }
/*--------------------------------------------------------- Notes ---*/ /* Notes... */
.editor .outline .NOTE { .editor .outline .NOTE {
--margin: 1rem; --margin: 1rem;
--padding-h: 2rem; --padding-h: 2rem;
@ -379,11 +376,9 @@ editor .outline .block:focus {
.editor .outline .NOTE>.view:empty { .editor .outline .NOTE>.view:empty {
display: none; display: none;
} }
.editor .outline .NOTE:focus>.view:empty { .editor .outline .NOTE>.view:empty ~ .block {
display: block; /* XXX calculate this... */
} margin-left: 1em;
.editor .outline .NOTE>.view:empty ~ .children {
margin-left: -1rem;
} }
.editor .outline .NOTE>.view:before { .editor .outline .NOTE>.view:before {
content: "" !important; content: "" !important;
@ -396,8 +391,7 @@ editor .outline .block:focus {
} }
/*--------------------------------------------------- Highlightes ---*/ /* Highlightes... */
.editor .outline .highlight { .editor .outline .highlight {
font-weight: bold; font-weight: bold;
background: yellow; background: yellow;
@ -407,8 +401,7 @@ editor .outline .block:focus {
} }
/*------------------------------------------------------ Comments ---*/ /* Comments... */
.editor.hide-comments .outline .comment { .editor.hide-comments .outline .comment {
display: none; display: none;
} }
@ -417,8 +410,7 @@ editor .outline .block:focus {
} }
/*---------------------------------------------------- Checkboxes ---*/ /* Checkboxes... */
.editor .outline .block.todo>.view { .editor .outline .block.todo>.view {
width: calc( width: calc(
100% 100%
@ -455,25 +447,16 @@ editor .outline .block:focus {
} }
/*---------------------------------------------------------- Code ---*/ /* code... */
.editor .outline .block>.view code {
.editor .outline .block>.view pre,
.editor .outline .block>.view>code,
.editor .outline .block>.view :not(pre)>code {
padding: 0.1em 0.3em; padding: 0.1em 0.3em;
font-family: monospace; font-family: monospace;
background: rgba(0,0,0,0.07); background: rgba(0,0,0,0.07);
border-radius: 0.2em; border-radius: 0.2em;
} }
.editor .outline .block>.view pre>code {
display: block;
padding: 0.6em 0.6em;
padding-bottom: 0.8em;
}
/*-------------------------------------------------------- Tables ---*/ /* Tables... */
.editor .outline .block>.view>table { .editor .outline .block>.view>table {
width: 100%; width: 100%;
border-collapse: collapse; border-collapse: collapse;

View File

@ -316,8 +316,6 @@ var Outline = {
if(code.trim() == ''){ if(code.trim() == ''){
elem.text = '' elem.text = ''
return elem } return elem }
// helpers...
var style = function(style, code=undefined){ var style = function(style, code=undefined){
style = [style].flat() style = [style].flat()
that.__styles = [...new Set([ that.__styles = [...new Set([
@ -329,29 +327,16 @@ var Outline = {
elem.style.push(...style) elem.style.push(...style)
return code return code
?? text } } ?? text } }
var quoteText = function(text){
return text
.replace(/(?<!\\)&/g, '&amp;')
.replace(/(?<!\\)</g, '&lt;')
.replace(/(?<!\\)>/g, '&gt;')
.replace(/\\(?!`)/g, '\\\\') }
var quote = function(_, code){
return `<code>${quoteText(code)}</code>` }
var pre = function(_, language, code){
language = language ?
'language-'+language
: language
return `<pre><code class="${language}">${ quoteText(code) }</code></pre>` }
var table = function(_, body){ var table = function(_, body){
return `<table><tr><td>${ return `<table><tr><td>${
body body
.replace(/\s*\|\s*\n\s*\|\s*/gm, '</td></tr>\n<tr><td>') .replace(/\s*\|\s*\n\s*\|\s*/gm, '</td></tr>\n<tr><td>')
.replace(/\s*\|\s*/gm, '</td><td>') .replace(/\s*\|\s*/gm, '</td><td>')
}</td></td></table>` } }</td></td></table>` }
elem.text = code elem.text = code
// hidden attributes... // hidden attributes...
// XXX make this generic... // XXX make this generic...
// XXX should these be hidden from code too???
// collapsed... // collapsed...
.replace(/(\n|^)\s*collapsed::\s*(.*)\s*(\n|$)/, .replace(/(\n|^)\s*collapsed::\s*(.*)\s*(\n|$)/,
function(_, value){ function(_, value){
@ -403,9 +388,7 @@ var Outline = {
.replace(/(?<!\\)\*(?=[^\s*])(([^*]|\\\*)*[^\s*])(?<!\\)\*/gm, '<b>$1</b>') .replace(/(?<!\\)\*(?=[^\s*])(([^*]|\\\*)*[^\s*])(?<!\\)\*/gm, '<b>$1</b>')
.replace(/(?<!\\)~(?=[^\s~])(([^~]|\\~)*[^\s~])(?<!\\)~/gm, '<s>$1</s>') .replace(/(?<!\\)~(?=[^\s~])(([^~]|\\~)*[^\s~])(?<!\\)~/gm, '<s>$1</s>')
.replace(/(?<!\\)_(?=[^\s_])(([^_]|\\_)*[^\s_])(?<!\\)_/gm, '<i>$1</i>') .replace(/(?<!\\)_(?=[^\s_])(([^_]|\\_)*[^\s_])(?<!\\)_/gm, '<i>$1</i>')
// code/quoting... .replace(/(?<!\\)`(?=[^\s])(([^`]|\\`)*[^\s])(?<!\\)`/gm, '<code>$1</code>')
.replace(/(?<!\\)```(.*)\s*\n((\n|.)*)\h*(?<!\\)```\s*/g, pre)
.replace(/(?<!\\)`(?=[^\s])(([^`]|\\`)*[^\s])(?<!\\)`/gm, quote)
// XXX support "\==" in mark... // XXX support "\==" in mark...
.replace(/(?<!\\)==(?=[^\s])(.*[^\s])(?<!\\)==/gm, '<mark>$1</mark>') .replace(/(?<!\\)==(?=[^\s])(.*[^\s])(?<!\\)==/gm, '<mark>$1</mark>')
// links... // links...
@ -588,9 +571,7 @@ var Outline = {
&& (code.innerHTML = this.text()) && (code.innerHTML = this.text())
return this }, return this },
// XXX move the code here into methods/actions...
// XXX add scrollIntoView(..) to nav... // XXX add scrollIntoView(..) to nav...
// XXX use keyboard.js...
keyboard: { keyboard: {
// vertical navigation... // vertical navigation...
// XXX this is a bit hacky but it works -- the caret blinks at // XXX this is a bit hacky but it works -- the caret blinks at
@ -825,11 +806,7 @@ var Outline = {
if(node.nodeName == 'TEXTAREA' if(node.nodeName == 'TEXTAREA'
&& node?.nextElementSibling?.nodeName == 'SPAN'){ && node?.nextElementSibling?.nodeName == 'SPAN'){
var block = node.parentElement var block = node.parentElement
that.update(block, { text: node.value }) } that.update(block, { text: node.value }) } })
// XXX do a plugin...
window.hljs
&& hljs.highlightAll() })
// update .code... // update .code...
var update_code_timeout var update_code_timeout
outline.addEventListener('change', outline.addEventListener('change',

View File

@ -2,10 +2,7 @@
<html> <html>
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
<link rel="stylesheet" href="css/default.css"> <link href="editor.css" rel="stylesheet"/>
<link rel="stylesheet" href="editor.css"/>
<style> <style>
.add-row { .add-row {
@ -13,9 +10,6 @@
} }
</style> </style>
<script src="lib/highlight.min.js"></script>
<script src="generic.js"></script> <script src="generic.js"></script>
<script src="editor.js"></script> <script src="editor.js"></script>
<script> <script>
@ -26,11 +20,7 @@ var setup = function(){
window.editor = { window.editor = {
__proto__: Outline, __proto__: Outline,
}.setup( }.setup(
document.querySelector('.editor')) document.querySelector('.editor')) }
// XXX make this a plugin...
window.hljs
&& hljs.highlightAll() }
</script> </script>
</head> </head>
@ -45,22 +35,17 @@ var setup = function(){
- Tomboy - Tomboy
- Bonsai - Bonsai
- -
- ## Bugs:
- BUG: ASAP: editor: `-` at start of line is interpreted as block marker...
- need to either:
- quote the `-` in .text() -- _preferreed_
- split the lines starting with `-` into nested nodes (a-la .load())
- BUG? pressing down from a longer line will jump over a shorter line
- to reproduce\:
- here is the line to jump from, for example from here
an we'll not get here...
-
- ## ToDo: - ## ToDo:
- BUG? pressing down from a longer line will jump over a shorter line
- here is the line to jump from, for example from here
an we'll not get here...
- ASAP: fix quotes
- Example: /\n\s*\|\s+/ -&gt; &lt;tr&gt;&lt;td&gt;
- ASAP: editor: bksapce/del at start/end of a block should join it with prev/next - ASAP: editor: bksapce/del at start/end of a block should join it with prev/next
- ASAP: editor: pressing enter in text edit mode should split text into two blocks - ASAP: editor: pressing enter in text edit mode should split text into two blocks
- ASAP: editor: shifting nodes up/down - ASAP: editor: shifting nodes up/down
- ASAP: editor: `-` at start of line is interpreted as block marker...
- ASAP: use \\t for indent... - ASAP: use \\t for indent...
- ASAP: scroll into view is bad...
- on item click, place the cursor where it was clicked before the code expanded... - on item click, place the cursor where it was clicked before the code expanded...
- ~editor: semi-live update styles~ - ~editor: semi-live update styles~
- need to reach checkboxes via keyboard - need to reach checkboxes via keyboard
@ -69,7 +54,7 @@ var setup = function(){
- _...use `[%]`, `%%`, or something similar..._ - _...use `[%]`, `%%`, or something similar..._
- read-only mode - read-only mode
- should bulets be on the same level as nodes or offset?? - should bulets be on the same level as nodes or offset??
- A) justified to bullet: - A) justified to bulet:
* list item * list item
* list item * list item
block text block text
@ -78,8 +63,6 @@ var setup = function(){
* list item * list item
block text block text
- NOTE: this is only a problem if making list-items manually -- disable??? - NOTE: this is only a problem if making list-items manually -- disable???
- FF: figure out a way to draw expand/collapse bullets without the use of CSS' `:has(..)`
- Nerd fonts (options?)
- ~do a better expand/collapse icons~ - ~do a better expand/collapse icons~
- ~loading from DOM -- fill textarea~ - ~loading from DOM -- fill textarea~
- ~focus management~ - ~focus management~
@ -97,6 +80,10 @@ var setup = function(){
- indent/deindent - indent/deindent
- edit node - edit node
- empty item height is a bit off... - empty item height is a bit off...
- ~handle links gracefully -- open/edit
_just click in the empty space_~
- ~<a href="about:blank">this takes the whole element</a>~
- this breaks if link is exactly line width -- should we ensure empty space?
- ~serialize/deserialize~ - ~serialize/deserialize~
- ~add optional text styling to nodes~ - ~add optional text styling to nodes~
- -
@ -138,7 +125,7 @@ var setup = function(){
- y - y
- z - z
- c - c
- > quote - &gt; quoted text
- Notes - Notes
- NOTE: a note text - NOTE: a note text
- NOTE: - NOTE:
@ -149,37 +136,33 @@ var setup = function(){
- XXX Highlight - XXX Highlight
- Basic inline *bold*, _italic_ and ~striked~ - Basic inline *bold*, _italic_ and ~striked~
- Marking ==text== - Marking ==text==
- Code
- Inline quoting `html <b>code</b>`
- code blocks
```javascript
var text = 'Hello, world!'
console.log(text)
```
- Line - Line
- --- - ---
- Markers: ASAP, BUG, FIX, HACK, STUB, WARNING, and CAUTION - Markers: ASAP, BUG, FIX, HACK, STUB, WARNING, and CAUTION
- Basic task management - Inline [X] checkboxes [_]
- Inline [X] checkboxes [_] - To do items/blocks
- To do items/blocks - [_] undone item
- [_] undone item _(clicking the checkbox updates the item)_
_(clicking the checkbox updates the item)_ - [X] done item
- [X] done item - [_] we can also add inline [x] checkboxes
- [_] we can also add inline [x] checkboxes - link
- links
- [example](about:blank) - [example](about:blank)
- https://example.com - https://example.com
- ./path/to/file /path/to -- _not supported yet_ - ./path/to/file /path/to -- not supported yet
- Tables - Tables
- | a | b | c | - | a | b | c |
| 1 | 2 | 3 | | 1 | 2 | 3 |
| 11 | 22 | 33 | | 11 | 22 | 33 |
- Symbols -- _should these be ligatures?_ - Symbols -- should these be ligatures?
- (i), (c), /!\, ... - (i), (c), /!\, ...
- -- and --- - -- and ---
- - markdown:
- --- - numbered lists
- ~tables~
- code blocks
- ~alerts~
- footnotes??
-
- ### Playground for testing - ### Playground for testing
- A - A
collapsed:: true collapsed:: true