mirror of
https://github.com/flynx/pWiki.git
synced 2025-12-25 20:31:58 +00:00
Compare commits
3 Commits
f1288fcc4f
...
42095da907
| Author | SHA1 | Date | |
|---|---|---|---|
| 42095da907 | |||
| 99da7ca626 | |||
| 5b0967f032 |
@ -173,6 +173,7 @@ var getMarkdownOffset = function(markdown, text, i){
|
||||
// (not implemented) backtracking...
|
||||
// ...needs thought...
|
||||
// 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){
|
||||
i = i ?? text.length
|
||||
var map = []
|
||||
@ -255,12 +256,12 @@ var blocks = {
|
||||
return text
|
||||
// markdown...
|
||||
// style: headings...
|
||||
.replace(/^(?<!\\)######\s+(.*)$/m, this.style(editor, elem, 'heading-6'))
|
||||
.replace(/^(?<!\\)#####\s+(.*)$/m, this.style(editor, elem, 'heading-5'))
|
||||
.replace(/^(?<!\\)####\s+(.*)$/m, this.style(editor, elem, 'heading-4'))
|
||||
.replace(/^(?<!\\)###\s+(.*)$/m, this.style(editor, elem, 'heading-3'))
|
||||
.replace(/^(?<!\\)##\s+(.*)$/m, this.style(editor, elem, 'heading-2'))
|
||||
.replace(/^(?<!\\)#\s+(.*)$/m, this.style(editor, elem, 'heading-1'))
|
||||
.replace(/^(?<!\\)######\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-6']))
|
||||
.replace(/^(?<!\\)#####\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-5']))
|
||||
.replace(/^(?<!\\)####\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-4']))
|
||||
.replace(/^(?<!\\)###\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-3']))
|
||||
.replace(/^(?<!\\)##\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-2']))
|
||||
.replace(/^(?<!\\)#\s+(.*)$/m, this.style(editor, elem, ['heading', 'heading-1']))
|
||||
// style: list...
|
||||
//.replace(/^(?<!\\)[-\*]\s+(.*)$/m, style('list-item'))
|
||||
.replace(/^\s*(.*)(?<!\\):\s*$/m, this.style(editor, elem, 'list'))
|
||||
@ -611,6 +612,53 @@ 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...
|
||||
@ -1144,6 +1192,7 @@ var Outline = {
|
||||
// NOTE: this needs to be before styling to prevent it from
|
||||
// treating '[_] ... [_]' as italic...
|
||||
tasks,
|
||||
toc,
|
||||
styling,
|
||||
// XXX
|
||||
//attributes,
|
||||
@ -1273,7 +1322,7 @@ var Outline = {
|
||||
outline
|
||||
: node.parentElement === outline ?
|
||||
outline
|
||||
: node.parentElement.parentElement }
|
||||
: node?.parentElement?.parentElement }
|
||||
var children = function(node){
|
||||
return node === outline ?
|
||||
[...node.children]
|
||||
@ -1922,7 +1971,7 @@ var Outline = {
|
||||
var line = edited.getTextGeometry().line
|
||||
if(line == 0){
|
||||
evt.preventDefault()
|
||||
that.focus('edited', 'prev') }
|
||||
that.edit('prev') }
|
||||
} else {
|
||||
evt.preventDefault()
|
||||
this.focus('focused', -1) } },
|
||||
@ -1943,9 +1992,9 @@ var Outline = {
|
||||
var edited = this.get('edited')
|
||||
if(edited){
|
||||
var {line, lines} = edited.getTextGeometry()
|
||||
if(line == lines - 1){
|
||||
if(lines == 0 || line == lines - 1){
|
||||
evt.preventDefault()
|
||||
that.focus('edited', 'next') }
|
||||
that.edit('next') }
|
||||
} else {
|
||||
evt.preventDefault()
|
||||
this.focus('focused', 1) } },
|
||||
@ -2088,7 +2137,8 @@ var Outline = {
|
||||
var a = edited.selectionStart
|
||||
var b = edited.selectionEnd
|
||||
// position 0: focus empty node above...
|
||||
if(a == 0){
|
||||
if(a == 0
|
||||
&& edited.value.trim() != ''){
|
||||
this.Block('prev')
|
||||
this.edit('prev')
|
||||
// focus new node...
|
||||
@ -2480,6 +2530,7 @@ var Outline = {
|
||||
setTimeout(function(){
|
||||
that.focus() }, 0) }
|
||||
/*/
|
||||
// XXX this for some reason takes lots of time at this point...
|
||||
this.focus() }
|
||||
//*/
|
||||
|
||||
|
||||
@ -48,17 +48,14 @@ var setup = function(){
|
||||
-
|
||||
- ## Bugs:
|
||||
focused:: true
|
||||
- BUG: navigation in edit mode broken...
|
||||
-
|
||||
- // can't go past this down...
|
||||
-
|
||||
- BUG: caret positioning broken
|
||||
- Example:
|
||||
- *TODO*::
|
||||
- text text text
|
||||
<div>
|
||||
block element
|
||||
</div>
|
||||
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(..)`_
|
||||
- ```
|
||||
m = `text text text
|
||||
@ -72,30 +69,30 @@ var setup = function(){
|
||||
this returns `69` while it should return `5`
|
||||
_...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)
|
||||
- clicking right of the last line places cursor wrong
|
||||
- _this is a problem with the new version of `getMarkdownOffset(..)`_
|
||||
- DONE text text text
|
||||
- DONE text text text
|
||||
- *DONE*::
|
||||
collapsed:: true
|
||||
- text text text
|
||||
- text text text
|
||||
text text text
|
||||
text text text
|
||||
- DONE M
|
||||
- M
|
||||
M can't place cursor before first char
|
||||
M
|
||||
- DONE 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
|
||||
- DONE _text text text_
|
||||
- _text text text_
|
||||
text text text
|
||||
- DONE ```
|
||||
- ```
|
||||
text text text
|
||||
```
|
||||
text text text
|
||||
- DONE |text|text|text|
|
||||
- |text|text|text|
|
||||
|text|text|text|
|
||||
|text|text|text|
|
||||
- BUG: parser: code blocks do not ignore single back-quotes...
|
||||
@ -112,9 +109,17 @@ var setup = function(){
|
||||
- normal textarea is not sized correctly
|
||||
- General:
|
||||
- bullets are too close to text
|
||||
- side margins are a bit too large (account for toolbat to the right)
|
||||
- side margins are a bit too large
|
||||
- still need to account for toolbar to the right
|
||||
- left side does not need to be as wide
|
||||
-
|
||||
- ## 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???
|
||||
- _...I'm leaning towards the later..._
|
||||
- Q: can we place a cursor in a table correctly???
|
||||
@ -178,6 +183,7 @@ var setup = function(){
|
||||
- numbered lists: add counters to a depth of 6-7...
|
||||
- _or find a way to make them repeat..._
|
||||
- FEATURE: read-only mode
|
||||
- FEATURE: TOC (???)
|
||||
- FEATURE: auto-shift done blocks to the end of siblings... (option?)
|
||||
- ...or should this be `sort:: done` -- i.e. sort children by done status??
|
||||
- codeblock as a block
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user