disabled manual headings + notes...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2023-12-17 06:08:46 +03:00
parent 29650ba7c9
commit d5950dc742
3 changed files with 29 additions and 17 deletions

View File

@ -380,34 +380,34 @@
border-bottom: solid 1px rgba(0,0,0,0.1); border-bottom: solid 1px rgba(0,0,0,0.1);
} }
} }
.auto.heading .auto.heading .auto.heading .auto.heading>.text, .heading .heading .heading .heading>.text,
.heading-4>.text, .heading-4>.text,
.heading-5>.text, .heading-5>.text,
.heading-6>.text { .heading-6>.text {
border-bottom: none; border-bottom: none;
} }
.auto.heading>.text, .heading>.text,
.heading-1>.text { .heading-1>.text {
--font-size: 2.5em; --font-size: 2.5em;
} }
.auto.heading .auto.heading>.text, .heading .heading>.text,
.heading-2>.text { .heading-2>.text {
--font-size: 1.9em; --font-size: 1.9em;
} }
.auto.heading .auto.heading .auto.heading>.text, .heading .heading .heading>.text,
.heading-3>.text { .heading-3>.text {
--font-size: 1.5em; --font-size: 1.5em;
} }
.auto.heading .auto.heading .auto.heading .auto.heading>.text, .heading .heading .heading .heading>.text,
.heading-4>.text { .heading-4>.text {
--font-size: 1.3em; --font-size: 1.3em;
} }
.auto.heading .auto.heading .auto.heading .auto.heading .auto.heading>.text, .heading .heading .heading .heading .heading>.text,
.heading-5>.text { .heading-5>.text {
--font-size: 1.1em; --font-size: 1.1em;
} }
.auto.heading .auto.heading .auto.heading .auto.heading .auto.heading .auto.heading>.text, .heading .heading .heading .heading .heading .heading>.text,
.heading-6>.text { .heading-6>.text {
--font-size: 1em; --font-size: 1em;
} }

View File

@ -216,6 +216,7 @@ var attributes = {
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX convert auto-heading to markdown heading level and back...
var blocks = { var blocks = {
__proto__: plugin, __proto__: plugin,
@ -223,6 +224,7 @@ var blocks = {
return text return text
// markdown... // markdown...
// style: headings... // style: headings...
/* XXX chose either this or auto headings -- move docs...
.replace(/^(?<!\\)######\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-6'])) .replace(/^(?<!\\)######\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-6']))
.replace(/^(?<!\\)#####\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-5'])) .replace(/^(?<!\\)#####\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-5']))
.replace(/^(?<!\\)####\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-4'])) .replace(/^(?<!\\)####\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-4']))
@ -230,11 +232,12 @@ var blocks = {
.replace(/^(?<!\\)##\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-2'])) .replace(/^(?<!\\)##\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-2']))
.replace(/^(?<!\\)#\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-1'])) .replace(/^(?<!\\)#\s+(.*)$/, this.style(editor, elem, ['heading', 'heading-1']))
// XXX EXPERIMENTAL // XXX EXPERIMENTAL
// XXX rename css class to "heading" .replace(/^(?<!\\)@+\s+(.*)$/, this.style(editor, elem, ['heading', 'auto']))
// XXX chose either this or manual headings... /*/
// XXX if this is used change syntax to '#' // XXX EXPERIMENTAL
//.replace(/^(?<!\\)#\s+(.*)$/, this.style(editor, elem, ['heading'])) .replace(/^(?<!\\)#+\s+(.*)$/, this.style(editor, elem, ['heading']))
.replace(/^(?<!\\)@\s+(.*)$/, this.style(editor, elem, ['heading', 'auto'])) .replace(/^(?<!\\)@+\s+(.*)$/, this.style(editor, elem, ['heading', 'no-toc']))
//*/
// style: list... // style: list...
//.replace(/^(?<!\\)[-\*]\s+(.*)$/m, style('list-item')) //.replace(/^(?<!\\)[-\*]\s+(.*)$/m, style('list-item'))
.replace(/^\s*(.*)(?<!\\):\s*$/, this.style(editor, elem, 'list')) .replace(/^\s*(.*)(?<!\\):\s*$/, this.style(editor, elem, 'list'))
@ -640,8 +643,9 @@ var toc = {
for(var e of [...root.querySelectorAll('.block.heading>.view')]){ for(var e of [...root.querySelectorAll('.block.heading>.view')]){
var block = editor.get(e) var block = editor.get(e)
// skip the root element??? // skip the root element???
if(!that.__skip_local_root__ if(block.classList.contains('no-toc')
&& block === root){ || (!that.__skip_local_root__
&& block === root)){
continue } continue }
var d = level(e, root) var d = level(e, root)
// down... // down...
@ -669,7 +673,7 @@ var toc = {
var list = makeTOC() var list = makeTOC()
for(var toc of TOCs){ for(var toc of TOCs){
toc.innerHTML = '' toc.innerHTML = ''
toc.append(list) } toc.append(list.cloneNode(true)) }
// local tocs... // local tocs...
for(var toc of tocs){ for(var toc of tocs){
toc.innerHTML = '' toc.innerHTML = ''
@ -1094,6 +1098,7 @@ var JSONOutline = {
// XXX // XXX
json: function(){}, json: function(){},
// XXX add plugin hooks...
// XXX add option to customize indent size... // XXX add option to customize indent size...
text: function(node, indent, level){ text: function(node, indent, level){
// .text(<indent>, <level>) // .text(<indent>, <level>)

View File

@ -45,6 +45,8 @@ var setup = function(){
- Google Keep (editor) - Google Keep (editor)
- -
- // Seems that I unintentionally implemented quite a chunk of the markdown spec ;) - // Seems that I unintentionally implemented quite a chunk of the markdown spec ;)
- ### Index
- TOC
- -
- ## Bugs: - ## Bugs:
focused:: true focused:: true
@ -141,8 +143,13 @@ var setup = function(){
|text|text|text| |text|text|text|
- -
- ## ToDo: - ## ToDo:
- Q: should auto-headings be exported as normal/manual markdown headings??? - TOC: Q: should we have both manual and auto headings???
- expand sub-tree on follow link... - IMHO: no...
- DONE TOC: headings that do not show up in toc -- `# ...` shows up while `@ ...` does not...
- TOC: tweaking: add args like depth, ...
- ASAP: expand sub-tree on follow link...
- export auto-headings as normal/manual markdown headings...
- plugin callback on save...
- 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_
- Might be a good idea to think how to avoid the constant selections on focus... - Might be a good idea to think how to avoid the constant selections on focus...