basic templating functional -- still needs work...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2025-02-10 06:39:01 +03:00
parent 7d45f89dfe
commit debb98faa1

View File

@ -348,14 +348,28 @@ var templates = {
// XXX restrict this to the button??? // XXX restrict this to the button???
__click__: function(evt, editor, elem){ __click__: function(evt, editor, elem){
if(evt.target.tagName == 'BUTTON'){ if(evt.target.tagName == 'BUTTON'){
//var node = editor.get(elem) // get template data...
// var data = editor.data(elem)
// XXX get the template data... // subtree...
var data = {} if(data.children.length > 0){
data = data.children[0]
// text...
} else {
data.text = data.text
.split(/\n/)
.slice(1)
.join('\n') }
// XXX handle cursor placement / selection...
// XXX
// XXX how do we get this???
var direction = 'next' var direction = 'next'
editor.focus(elem) editor.focus(elem)
editor.edit( editor.edit(
// XXX BUG? currently this only creates a single node,
// should be recursive...
editor.Block(data, direction)) } }, editor.Block(data, direction)) } },
} }