Compare commits

...

2 Commits

Author SHA1 Message Date
1a0e7b9d69 started work on templates...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2025-02-08 15:01:09 +03:00
9d83f807da added template examples...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
2025-02-07 13:56:12 +03:00
3 changed files with 83 additions and 0 deletions

View File

@ -221,6 +221,8 @@
/* clickable things in view */ /* clickable things in view */
& a, & a,
& pre, & pre,
& button,
& select,
& input { & input {
pointer-events: auto; pointer-events: auto;
} }

View File

@ -309,6 +309,46 @@ var attributes = {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX make this collapsed...
// XXX handle cursor marker...
var templates = {
__proto__: plugin,
nodeFromTemplate: function(){
},
__pre_parse__: function(text, editor, elem){
if(!text.startsWith('TEMPLATE')){
return text }
text = text
.replace(/^TEMPLATE/, '')
var [header, ...lines] = text.split(/\n/g)
header =
`<button>${
header.trim() == '' ?
'new'
: header.trim()
}</button>`
// body...
// XXX only do this if we have nested elements...
elem.collapsed = true
// XXX
// button...
return header },
// XXX focus button...
__focusin__: function(evt, editor, elem){
},
// XXX handle button???
__click__: function(evt, editor, elem){
},
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX revise headings... // XXX revise headings...
@ -967,6 +1007,7 @@ var JSONOutline = {
// XXX split out DOM-specific plugins into Outline.plugins... // XXX split out DOM-specific plugins into Outline.plugins...
pre_plugins: [ pre_plugins: [
attributes, attributes,
templates,
blocks, blocks,
quoted, quoted,
], ],

View File

@ -155,6 +155,46 @@ var setup = function(){
|text|text|text| |text|text|text|
- -
- ## ToDo: - ## ToDo:
- Item templates:
- inline
- TEMPLATE
text [cursor]
- TEMPLATE title
text [cursor]
- sub-tree
- TEMPLATE title
- text [cursor]
- multi-template
- TEMPLATE title A
text [cursor]
- TEMPLATE title B
- text [cursor]
- renders as:
- <button>title</button>
- <select>
<option>title A</option>
<option>title B</option>
</select><button>new</button>
- action:
- duplicate template text / subtree (w.o. markers)
- select / place cursor at cursor marker
- TODO:
- nested templates??
- global templates -- or should this be an external macro???
- revise syntax
- templated lists -- a list that uses a template for it's items
- something like:
- or here there is an explicit item template
- TEMPLATE new
- [ ] [cursor]
- [ ] A
- [ ] B
- [ ] C
- and a shorthand for todo:
- TODO in lists like this new items will be created with a todo template
- [ ] A
- [ ] B
- [ ] C
- Time to think about a standalone client -- at least to edit own notes as a test... - Time to think about a standalone client -- at least to edit own notes as a test...
- _also this would be a nice opportunity to start the move to a newer electron version_ - _also this would be a nice opportunity to start the move to a newer electron version_
- Deployment: - Deployment: