Compare commits

..

No commits in common. "42095da90717978420fcec70079d54aa088a0df2" and "f1288fcc4f5f336f71c6a9ad4ce9df31d70d1f85" have entirely different histories.

2 changed files with 27 additions and 84 deletions

View File

@ -173,7 +173,6 @@ var getMarkdownOffset = function(markdown, text, i){
// (not implemented) backtracking... // (not implemented) backtracking...
// ...needs thought... // ...needs thought...
// Q: can we cheat with this? =) // Q: can we cheat with this? =)
// XXX BUG: clicking right of last line places the caret before the last char...
var getMarkdownOffset = function(markdown, text, i){ var getMarkdownOffset = function(markdown, text, i){
i = i ?? text.length i = i ?? text.length
var map = [] var map = []
@ -256,12 +255,12 @@ var blocks = {
return text return text
// markdown... // markdown...
// style: headings... // style: headings...
.replace(/^(?<!\\)######\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-6'])) .replace(/^(?<!\\)######\s+(.*)$/m, this.style(editor, elem, 'heading-6'))
.replace(/^(?<!\\)#####\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-5'])) .replace(/^(?<!\\)#####\s+(.*)$/m, this.style(editor, elem, 'heading-5'))
.replace(/^(?<!\\)####\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-4'])) .replace(/^(?<!\\)####\s+(.*)$/m, this.style(editor, elem, 'heading-4'))
.replace(/^(?<!\\)###\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-3'])) .replace(/^(?<!\\)###\s+(.*)$/m, this.style(editor, elem, 'heading-3'))
.replace(/^(?<!\\)##\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-2'])) .replace(/^(?<!\\)##\s+(.*)$/m, this.style(editor, elem, 'heading-2'))
.replace(/^(?<!\\)#\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-1'])) .replace(/^(?<!\\)#\s+(.*)$/m, this.style(editor, elem, 'heading-1'))
// style: list... // style: list...
//.replace(/^(?<!\\)[-\*]\s+(.*)$/m, style('list-item')) //.replace(/^(?<!\\)[-\*]\s+(.*)$/m, style('list-item'))
.replace(/^\s*(.*)(?<!\\):\s*$/m, this.style(editor, elem, 'list')) .replace(/^\s*(.*)(?<!\\):\s*$/m, this.style(editor, elem, 'list'))
@ -612,53 +611,6 @@ var tasks = {
} }
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX needs lots more work...
var toc = {
__proto__: plugin,
// XXX not sure on what to build the hierarchy...
// this could be:
// - heading level
// - topology
// - both
// - ...
update: function(editor, elem){
var outline = editor.outline
var tocs = [...outline.querySelectorAll('.toc .view')]
if(tocs.length == 0){
return }
var level = function(node){
var depth = 0
var parent = node
while(parent !== outline
&& parent != null){
if(parent.classList.contains('block')){
depth++ }
parent = parent.parentElement }
return depth }
var headings = [...editor.outline.querySelectorAll('.block.heading>.view')]
.map(function(e){
return `<li>${ e.innerText.split(/\n/)[0] }</li>`
})
var lst = document.createElement('ul')
lst.innerHTML = headings.join('\n')
for(var toc of tocs){
toc.append(lst) } },
__setup__: function(editor){
return this.update(editor) },
__editedcode__: function(evt, editor, elem){
return this.update(editor, elem) },
__parse__: function(text, editor, elem){
return text
.replace(/^\s*TOC\s*$/,
this.style(editor, elem, 'toc', '')) },
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// XXX Hackish... // XXX Hackish...
@ -1192,7 +1144,6 @@ var Outline = {
// NOTE: this needs to be before styling to prevent it from // NOTE: this needs to be before styling to prevent it from
// treating '[_] ... [_]' as italic... // treating '[_] ... [_]' as italic...
tasks, tasks,
toc,
styling, styling,
// XXX // XXX
//attributes, //attributes,
@ -1322,7 +1273,7 @@ var Outline = {
outline outline
: node.parentElement === outline ? : node.parentElement === outline ?
outline outline
: node?.parentElement?.parentElement } : node.parentElement.parentElement }
var children = function(node){ var children = function(node){
return node === outline ? return node === outline ?
[...node.children] [...node.children]
@ -1971,7 +1922,7 @@ var Outline = {
var line = edited.getTextGeometry().line var line = edited.getTextGeometry().line
if(line == 0){ if(line == 0){
evt.preventDefault() evt.preventDefault()
that.edit('prev') } that.focus('edited', 'prev') }
} else { } else {
evt.preventDefault() evt.preventDefault()
this.focus('focused', -1) } }, this.focus('focused', -1) } },
@ -1992,9 +1943,9 @@ var Outline = {
var edited = this.get('edited') var edited = this.get('edited')
if(edited){ if(edited){
var {line, lines} = edited.getTextGeometry() var {line, lines} = edited.getTextGeometry()
if(lines == 0 || line == lines - 1){ if(line == lines - 1){
evt.preventDefault() evt.preventDefault()
that.edit('next') } that.focus('edited', 'next') }
} else { } else {
evt.preventDefault() evt.preventDefault()
this.focus('focused', 1) } }, this.focus('focused', 1) } },
@ -2137,8 +2088,7 @@ var Outline = {
var a = edited.selectionStart var a = edited.selectionStart
var b = edited.selectionEnd var b = edited.selectionEnd
// position 0: focus empty node above... // position 0: focus empty node above...
if(a == 0 if(a == 0){
&& edited.value.trim() != ''){
this.Block('prev') this.Block('prev')
this.edit('prev') this.edit('prev')
// focus new node... // focus new node...
@ -2530,7 +2480,6 @@ var Outline = {
setTimeout(function(){ setTimeout(function(){
that.focus() }, 0) } that.focus() }, 0) }
/*/ /*/
// XXX this for some reason takes lots of time at this point...
this.focus() } this.focus() }
//*/ //*/

View File

@ -48,14 +48,17 @@ var setup = function(){
- -
- ## Bugs: - ## Bugs:
focused:: true focused:: true
- BUG: navigation in edit mode broken...
-
- // can't go past this down...
-
- BUG: caret positioning broken - BUG: caret positioning broken
- *TODO*:: - Example:
- text text text - text text text
<div> <div>
block element block element
</div> </div>
this line, and above placement of completely broken this line, and above placement of completely broken
- the odd thing is that a nested (bug) qupted text below also breaks...
- _this seems to be an issue with: `.getMarkdownOffset(..)`_ - _this seems to be an issue with: `.getMarkdownOffset(..)`_
- ``` - ```
m = `text text text m = `text text text
@ -69,30 +72,30 @@ var setup = function(){
this returns `69` while it should return `5` this returns `69` while it should return `5`
_...replacing `\n\n\n` with `\n\n` seems to fix the issue (also works with spaces)_ _...replacing `\n\n\n` with `\n\n` seems to fix the issue (also works with spaces)_
(BUG also the above line is not italic -- can't reproduce) (BUG also the above line is not italic -- can't reproduce)
- *DONE*:: - clicking right of the last line places cursor wrong
collapsed:: true - _this is a problem with the new version of `getMarkdownOffset(..)`_
- text text text - DONE text text text
- text text text - DONE text text text
text text text text text text
text text text text text text
- M - DONE M
M can't place cursor before first char M can't place cursor before first char
M M
- text text text - DONE text text text
``` ```
text text text text text text
``` ```
text text text text text text
- text text text - DONE text text text
_text text text_ _text text text_
text text text text text text
- _text text text_ - DONE _text text text_
text text text text text text
- ``` - DONE ```
text text text text text text
``` ```
text text text text text text
- |text|text|text| - DONE |text|text|text|
|text|text|text| |text|text|text|
|text|text|text| |text|text|text|
- BUG: parser: code blocks do not ignore single back-quotes... - BUG: parser: code blocks do not ignore single back-quotes...
@ -109,17 +112,9 @@ var setup = function(){
- normal textarea is not sized correctly - normal textarea is not sized correctly
- General: - General:
- bullets are too close to text - bullets are too close to text
- side margins are a bit too large - side margins are a bit too large (account for toolbat to the right)
- still need to account for toolbar to the right
- left side does not need to be as wide
- -
- ## ToDo: - ## ToDo:
- ASAP 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 make the heading level depend on its depth...
- might be a good idea to think how to avoid the constant selections on focus...
- Q: do we want to place the caret when moving between nodes???
- _would be nice to remember the caret horizontal offset for vertical movement_
- Q: should we use `HTMLTextAreaElement.autoUpdateSize(..)` or handle it globally in setup??? - Q: should we use `HTMLTextAreaElement.autoUpdateSize(..)` or handle it globally in setup???
- _...I'm leaning towards the later..._ - _...I'm leaning towards the later..._
- Q: can we place a cursor in a table correctly??? - Q: can we place a cursor in a table correctly???
@ -183,7 +178,6 @@ var setup = function(){
- numbered lists: add counters to a depth of 6-7... - numbered lists: add counters to a depth of 6-7...
- _or find a way to make them repeat..._ - _or find a way to make them repeat..._
- FEATURE: read-only mode - FEATURE: read-only mode
- FEATURE: TOC (???)
- FEATURE: auto-shift done blocks to the end of siblings... (option?) - FEATURE: auto-shift done blocks to the end of siblings... (option?)
- ...or should this be `sort:: done` -- i.e. sort children by done status?? - ...or should this be `sort:: done` -- i.e. sort children by done status??
- codeblock as a block - codeblock as a block