mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 10:00:08 +00:00
reworking text selection + tweaks...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
3375ba26d7
commit
2f3255b53d
@ -183,6 +183,7 @@
|
|||||||
&>.view {
|
&>.view {
|
||||||
position: relative;
|
position: relative;
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
user-select: none;
|
||||||
|
|
||||||
/* clickable things in view */
|
/* clickable things in view */
|
||||||
& a,
|
& a,
|
||||||
|
|||||||
@ -66,6 +66,12 @@ var getCharOffset = function(elem, x, y, c){
|
|||||||
: null }
|
: null }
|
||||||
|
|
||||||
|
|
||||||
|
var getTextAreaOffset = function(elem, x, y){
|
||||||
|
return elem.getTextGeometry(function(res, elem){
|
||||||
|
// XXX this will not work as it needs correct placement of elem under the cursor...
|
||||||
|
return getCharOffset(elem, x, y) }) }
|
||||||
|
|
||||||
|
|
||||||
// Get offset in markdown relative to the resulting text...
|
// Get offset in markdown relative to the resulting text...
|
||||||
//
|
//
|
||||||
// v <----- position
|
// v <----- position
|
||||||
@ -2017,24 +2023,50 @@ var Outline = {
|
|||||||
// click...
|
// click...
|
||||||
// XXX revise...
|
// XXX revise...
|
||||||
// XXX tap support...
|
// XXX tap support...
|
||||||
|
// XXX support selection from first click... (see: mousemove handler)
|
||||||
|
var selecting, start
|
||||||
outline.addEventListener('mousedown',
|
outline.addEventListener('mousedown',
|
||||||
function(evt){
|
function(evt){
|
||||||
var elem = evt.target
|
var elem = evt.target
|
||||||
// place the cursor where the user clicked in code/text...
|
// place the cursor where the user clicked in code/text...
|
||||||
if(elem.classList.contains('code')
|
if(elem.classList.contains('code')
|
||||||
&& document.activeElement !== elem){
|
&& document.activeElement !== elem){
|
||||||
evt.preventDefault()
|
|
||||||
var view = that.get(elem).querySelector('.view')
|
var view = that.get(elem).querySelector('.view')
|
||||||
|
var initial = elem.selectionStart
|
||||||
var c = getCharOffset(view, evt.clientX, evt.clientY)
|
var c = getCharOffset(view, evt.clientX, evt.clientY)
|
||||||
if(c == null){
|
|
||||||
elem.focus()
|
|
||||||
elem.selectionStart = elem.value.length
|
|
||||||
elem.selectionEnd = elem.value.length
|
|
||||||
} else {
|
|
||||||
var m = getMarkdownOffset(elem.value, view.innerText, c)
|
var m = getMarkdownOffset(elem.value, view.innerText, c)
|
||||||
|
// selecting an element with text offset by markup...
|
||||||
|
if(m != 0){
|
||||||
|
evt.preventDefault()
|
||||||
|
selecting = elem }
|
||||||
|
start = c == null ?
|
||||||
|
elem.value.length
|
||||||
|
: c + m
|
||||||
|
// NOTE: this is done on next frame to allow the
|
||||||
|
// browser to place the caret before we correct
|
||||||
|
// its position... (if .preventDefault() was not called)
|
||||||
|
setTimeout(function(){
|
||||||
elem.focus()
|
elem.focus()
|
||||||
elem.selectionStart = c + m
|
elem.selectionStart =
|
||||||
elem.selectionEnd = c + m } } })
|
elem.selectionEnd =
|
||||||
|
start }, 0) } })
|
||||||
|
outline.addEventListener('mousemove',
|
||||||
|
function(evt){
|
||||||
|
// handle selection in element with text offset by markup...
|
||||||
|
// XXX should there be a timeout???
|
||||||
|
if(selecting != null){
|
||||||
|
// XXX need to get offset under cursor...
|
||||||
|
var c = getTextAreaOffset(selecting, evt.clientX, evt.clientY)
|
||||||
|
return
|
||||||
|
if(c > start){
|
||||||
|
selecting.selectionStart = start
|
||||||
|
selecting.selectionEnd = c
|
||||||
|
} else {
|
||||||
|
selecting.selectionStart = c
|
||||||
|
selecting.selectionEnd = start } } })
|
||||||
|
outline.addEventListener('mouseup',
|
||||||
|
function(evt){
|
||||||
|
selecting = undefined })
|
||||||
outline.addEventListener('click',
|
outline.addEventListener('click',
|
||||||
function(evt){
|
function(evt){
|
||||||
var elem = evt.target
|
var elem = evt.target
|
||||||
|
|||||||
@ -63,7 +63,7 @@ HTMLTextAreaElement.prototype.autoUpdateSize = function(){
|
|||||||
function(evt){
|
function(evt){
|
||||||
that.updateSize() })
|
that.updateSize() })
|
||||||
return this }
|
return this }
|
||||||
HTMLTextAreaElement.prototype.getTextGeometry = function(){
|
HTMLTextAreaElement.prototype.getTextGeometry = function(func){
|
||||||
var offset = this.selectionStart
|
var offset = this.selectionStart
|
||||||
var text = this.value
|
var text = this.value
|
||||||
|
|
||||||
@ -128,6 +128,9 @@ HTMLTextAreaElement.prototype.getTextGeometry = function(){
|
|||||||
offsetTop: carret.offsetTop,
|
offsetTop: carret.offsetTop,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(typeof(func) == 'function'){
|
||||||
|
res = func(res, span) }
|
||||||
|
|
||||||
span.remove()
|
span.remove()
|
||||||
|
|
||||||
return res }
|
return res }
|
||||||
|
|||||||
@ -75,6 +75,7 @@ var setup = function(){
|
|||||||
- selection
|
- selection
|
||||||
- DONE multiple node selection (via shift+motion)
|
- DONE multiple node selection (via shift+motion)
|
||||||
- fixed state -- while `shift` pressed select or deselect only depending on first action (a-la FAR)
|
- fixed state -- while `shift` pressed select or deselect only depending on first action (a-la FAR)
|
||||||
|
- DONE double/triple click working...
|
||||||
- touch/mouse (???)
|
- touch/mouse (???)
|
||||||
- Q: should we select text (mouse/touch) without first focusing??
|
- Q: should we select text (mouse/touch) without first focusing??
|
||||||
- _...logseq does not do this either_
|
- _...logseq does not do this either_
|
||||||
@ -83,10 +84,8 @@ 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
|
||||||
- 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??
|
||||||
- `backspace`/`delete` in block contract the field with a delay...
|
|
||||||
- _...looks like we are updating size on keyup..._
|
|
||||||
- codeblock as a block
|
- codeblock as a block
|
||||||
_...if only whitespace before/after clear it and style whole block..._
|
_...if only whitespace before/after clear it and style whole block..._
|
||||||
_...might be a good idea to do this with codeblock at start/end of block..._
|
_...might be a good idea to do this with codeblock at start/end of block..._
|
||||||
@ -100,15 +99,21 @@ var setup = function(){
|
|||||||
- cleanup html
|
- cleanup html
|
||||||
- generate ideomatic html (???)
|
- generate ideomatic html (???)
|
||||||
- style attrs (see: [attrs](#attributes))
|
- style attrs (see: [attrs](#attributes))
|
||||||
- FEATURE: `collapse-children:: true` block option -- when loading collapse all immediate children
|
|
||||||
- FF: figure out a way to draw expand/collapse bullets without the use of CSS' `:has(..)`
|
- FF: figure out a way to draw expand/collapse bullets without the use of CSS' `:has(..)`
|
||||||
- table inline editing a-la code editing -- click cell and edit directly...
|
- table inline editing a-la code editing -- click cell and edit directly...
|
||||||
- a way to make a block monospace (???)
|
|
||||||
- Nerd fonts (option???)
|
|
||||||
- smooth scrolling
|
- smooth scrolling
|
||||||
- _...this is more complicated than adding `behavior: "smooth"` to `.scrollIntoView(..)` as scrolling animation will get interrupted by next user input..._
|
- _...this is more complicated than adding `behavior: "smooth"` to `.scrollIntoView(..)` as scrolling animation will get interrupted by next user input..._
|
||||||
- need to cancel animation if things are moving too fast...
|
- need to cancel animation if things are moving too fast...
|
||||||
- make this generic (???)
|
- make this generic (???)
|
||||||
|
- JSON API
|
||||||
|
- cli
|
||||||
|
- Q: do we use \\t for indent? (option???)
|
||||||
|
- Q: persistent empty first/last node (a button to create a new node)?
|
||||||
|
- Q: search?
|
||||||
|
- _seems that search should be external to the editor_
|
||||||
|
- empty item height is a bit off...
|
||||||
|
- Nerd fonts (option???)
|
||||||
|
- FEATURE: `collapse-children:: true` block option -- when loading collapse all immediate children
|
||||||
- FEATURE? block templates...
|
- FEATURE? block templates...
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- something like: `TPL: [_] <editable/> -- <editable/>`
|
- something like: `TPL: [_] <editable/> -- <editable/>`
|
||||||
@ -116,24 +121,24 @@ var setup = function(){
|
|||||||
- `<editable/>` -- field marker
|
- `<editable/>` -- field marker
|
||||||
- each child node will copy the template and allow editing of only fields
|
- each child node will copy the template and allow editing of only fields
|
||||||
- not clear how to handle template changes...
|
- not clear how to handle template changes...
|
||||||
- JSON API
|
- DONE `backspace`/`delete` in block contract the field with a delay...
|
||||||
- cli
|
collapsed:: true
|
||||||
- Q: do we use \\t for indent? (option???)
|
- _...looks like we are updating size on keyup..._
|
||||||
- Q: persistent empty first/last node (a button to create a new node)?
|
- DONE Q: should list bullets be on the same level as nodes or offset??
|
||||||
- Q: should list bullets be on the same level as nodes or offset??
|
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- A) justified to bullet:
|
- A) justified to bullet:
|
||||||
|
```
|
||||||
* list item
|
* list item
|
||||||
* list item
|
* list item
|
||||||
block text
|
block text
|
||||||
|
```
|
||||||
|
_This is impossible to create in the current implementation_
|
||||||
- B) justified to text _(current)_:
|
- B) justified to text _(current)_:
|
||||||
|
```
|
||||||
* list item
|
* list item
|
||||||
* list item
|
* list item
|
||||||
block text
|
block text
|
||||||
- NOTE: this is only a problem if making list-items manually -- disable???
|
```
|
||||||
- empty item height is a bit off...
|
|
||||||
- search?
|
|
||||||
- _...not sure if search should be internal or external yet..._
|
|
||||||
- DONE add horizontal scroll to code blocks...
|
- DONE add horizontal scroll to code blocks...
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- ```html
|
- ```html
|
||||||
@ -168,6 +173,7 @@ var setup = function(){
|
|||||||
- DONE undo
|
- DONE undo
|
||||||
- DONE crop: make path clickable
|
- DONE crop: make path clickable
|
||||||
- DONE Q: crop: should we control crop via "crop-in"/"crop-out" instead of crop/uncrop??
|
- DONE Q: crop: should we control crop via "crop-in"/"crop-out" instead of crop/uncrop??
|
||||||
|
collapsed:: true
|
||||||
- _crop-in/crop-out seems more natural..._
|
- _crop-in/crop-out seems more natural..._
|
||||||
- DONE crop: show crop path (and depth)
|
- DONE crop: show crop path (and depth)
|
||||||
- DONE over-travel pause -- when going fast over start/end stop...
|
- DONE over-travel pause -- when going fast over start/end stop...
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user