working on attributes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-12-17 16:45:09 +03:00
parent d5950dc742
commit 7a7ac49432
2 changed files with 22 additions and 7 deletions

View File

@ -216,7 +216,7 @@ var attributes = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX convert auto-heading to markdown heading level and back...
// XXX revise headings...
var blocks = {
__proto__: plugin,
@ -1155,6 +1155,9 @@ var JSONOutline = {
: undefined
} else if(type == 'attr'
|| type == undefined){
// special case: dataset attrs...
if(type == undefined){
attr = 'data-'+ attr }
typeof(value) == 'boolean'?
(value ?
attrs.push(attr)
@ -1602,16 +1605,20 @@ var Outline = {
value ?
node.classList.add(attr)
: node.classList.remove(attr)
} else if(type == 'attr'
|| type == undefined){
} else if(type == 'attr'){
typeof(value) == 'boolean'?
(value ?
node.setAttribute(attr, '')
: node.removeAttribute(attr))
: value != null ?
node.setAttribute(attr, value)
: node.removeAttribute(attr) } }
: node.removeAttribute(attr)
// dataset...
} else {
if(value == null){
delete node.dataset[attr]
} else {
node.dataset[attr] = value } } }
this.__change__()
return node },
@ -1861,6 +1868,8 @@ var Outline = {
var attrs = this.__block_attrs__
var cls_attrs = ['focused']
return {
// NOTE: this is first to prevent it from overriding system attrs...
...elem.dataset,
text: elem.querySelector('.code').value,
...(Object.entries(attrs)
.reduce(function(res, [attr, type]){

View File

@ -143,13 +143,19 @@ var setup = function(){
|text|text|text|
-
- ## ToDo:
- attributes: `.data(..)`: read in element attributes...
- would be logical to store system attrs (`.__block_attrs__`) as attrs while the rest as data-attrs - this would bot simplify retrieval and avoid shadowing html attrs...
- TEST: this item has attr `moo` with value `"foo"`
moo::foo
- need a way to remove attributes from editor -- `null` or `undefined` special values??
- attributes: need to show/hide the attributes -- option?
- TOC: Q: should we have both manual and auto headings???
- IMHO: no...
- DONE TOC: headings that do not show up in toc -- `# ...` shows up while `@ ...` does not...
- TOC: tweaking: add args like depth, ...
- TOC: tweaking: add args like depth, ... -- as attributes...
- ASAP: expand sub-tree on follow link...
- export auto-headings as normal/manual markdown headings...
- plugin callback on save...
- add plugin callback on `.text(..)` / ...
- 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_
- Might be a good idea to think how to avoid the constant selections on focus...