mirror of
https://github.com/flynx/pWiki.git
synced 2025-10-29 18:10:09 +00:00
fixed text positioning...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
fbd55abddf
commit
f6fea34821
@ -40,6 +40,7 @@ HTMLTextAreaElement.prototype.getTextGeometry = function(){
|
|||||||
|
|
||||||
// get the relevant styles...
|
// get the relevant styles...
|
||||||
var style = getComputedStyle(this)
|
var style = getComputedStyle(this)
|
||||||
|
var paddingV = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)
|
||||||
var s = {}
|
var s = {}
|
||||||
for(var i=0; i < style.length; i++){
|
for(var i=0; i < style.length; i++){
|
||||||
var k = style[i]
|
var k = style[i]
|
||||||
@ -49,12 +50,11 @@ HTMLTextAreaElement.prototype.getTextGeometry = function(){
|
|||||||
s[k] = style[k] } }
|
s[k] = style[k] } }
|
||||||
|
|
||||||
var carret = document.createElement('span')
|
var carret = document.createElement('span')
|
||||||
carret.innerText = '|'
|
carret.innerText = '|'
|
||||||
carret.style.margin = '0px'
|
carret.style.margin = '0px'
|
||||||
carret.style.padding = '0px'
|
carret.style.padding = '0px'
|
||||||
|
|
||||||
var span = document.createElement('span')
|
var span = document.createElement('span')
|
||||||
span.innerText = text.slice(0, offset)
|
|
||||||
Object.assign(span.style, {
|
Object.assign(span.style, {
|
||||||
...s,
|
...s,
|
||||||
|
|
||||||
@ -62,24 +62,28 @@ HTMLTextAreaElement.prototype.getTextGeometry = function(){
|
|||||||
display: 'block',
|
display: 'block',
|
||||||
top: '-100%',
|
top: '-100%',
|
||||||
left: '-100%',
|
left: '-100%',
|
||||||
width: this.offsetWidth + 'px',
|
width: style.width,
|
||||||
height: this.scrollHeight + 'px',
|
height: style.height,
|
||||||
|
|
||||||
padding: style.padding,
|
padding: style.padding,
|
||||||
|
|
||||||
|
boxSizing: style.boxSizing,
|
||||||
|
|
||||||
outline: 'solid 1px red',
|
outline: 'solid 1px red',
|
||||||
|
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
})
|
})
|
||||||
span.append(carret)
|
span.append(
|
||||||
|
text.slice(0, offset),
|
||||||
|
carret,
|
||||||
|
text.slice(offset))
|
||||||
|
|
||||||
document.body.append(span)
|
document.body.append(span)
|
||||||
|
|
||||||
var padding = parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)
|
|
||||||
var res = {
|
var res = {
|
||||||
length: text.length,
|
length: text.length,
|
||||||
lines: Math.floor(
|
lines: Math.floor(
|
||||||
(this.offsetHeight - padding)
|
(this.offsetHeight - paddingV)
|
||||||
/ carret.offsetHeight),
|
/ carret.offsetHeight),
|
||||||
line: Math.floor(carret.offsetTop / carret.offsetHeight),
|
line: Math.floor(carret.offsetTop / carret.offsetHeight),
|
||||||
offset: offset,
|
offset: offset,
|
||||||
|
|||||||
@ -67,7 +67,7 @@ var setup = function(){
|
|||||||
- ...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
|
||||||
_...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..._
|
||||||
- Code blocks and bullets:
|
- Code blocks and bullets:
|
||||||
- ```
|
- ```
|
||||||
code
|
code
|
||||||
@ -77,8 +77,8 @@ var setup = function(){
|
|||||||
- FEATURE: read-only mode
|
- FEATURE: read-only mode
|
||||||
- export html
|
- export html
|
||||||
- embed css
|
- embed css
|
||||||
- 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
|
- 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(..)`
|
||||||
@ -93,9 +93,9 @@ var setup = function(){
|
|||||||
- make this generic
|
- make this generic
|
||||||
- FEATURE? block templates...
|
- FEATURE? block templates...
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- something like: `TPL: [_] <editable/> -- <editable/>`
|
- something like: `TPL: [_] <editable/> -- <editable/>`
|
||||||
- `TPL:` -- template marker
|
- `TPL:` -- template marker
|
||||||
- `<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
|
- JSON API
|
||||||
@ -123,7 +123,7 @@ var setup = function(){
|
|||||||
- DONE unify attr parsing
|
- DONE unify attr parsing
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- _now duplicated in `.parse(..)` and `.__code2html__(..)`_
|
- _now duplicated in `.parse(..)` and `.__code2html__(..)`_
|
||||||
- might be a good idea to add a special text parse stage and use in on both branches...
|
- might be a good idea to add a special text parse stage and use in on both branches...
|
||||||
- DONE attrs in editor are not parsed correctly (see: [attrs](#attributes))
|
- DONE attrs in editor are not parsed correctly (see: [attrs](#attributes))
|
||||||
- DONE multiple attrs are not handled correctly (see: [attrs](#attributes))
|
- DONE multiple attrs are not handled correctly (see: [attrs](#attributes))
|
||||||
- DONE call `.sync()` on all changes...
|
- DONE call `.sync()` on all changes...
|
||||||
@ -140,7 +140,7 @@ var setup = function(){
|
|||||||
- _not sure how..._
|
- _not sure how..._
|
||||||
- DONE click to select/edit node must retain click position in text...
|
- DONE click to select/edit node must retain click position in text...
|
||||||
- DONE checkbox navigation via `alt-<arrow>`
|
- DONE checkbox navigation via `alt-<arrow>`
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- _might be a good idea to include also TODO/DONE navigation -- not yet sure how to mark undone blocks (i.e. the ones marked with TODO in Logseg)..._
|
- _might be a good idea to include also TODO/DONE navigation -- not yet sure how to mark undone blocks (i.e. the ones marked with TODO in Logseg)..._
|
||||||
- toggle with `space`
|
- toggle with `space`
|
||||||
- navigation auto-selects first checkbox
|
- navigation auto-selects first checkbox
|
||||||
@ -166,8 +166,8 @@ var setup = function(){
|
|||||||
- ## Refactoring:
|
- ## Refactoring:
|
||||||
- Plugin architecture
|
- Plugin architecture
|
||||||
- DONE basic structure
|
- DONE basic structure
|
||||||
- plugin handler sequencing (see: `<editor>.setup(..)`)
|
- plugin handler sequencing (see: `<editor>.setup(..)`)
|
||||||
- DONE plugin handler canceling (see: `<editor>.runPlugins(..)`)
|
- DONE plugin handler canceling (see: `<editor>.runPlugins(..)`)
|
||||||
- DONE Item parser (`.__code2html__(..)`)
|
- DONE Item parser (`.__code2html__(..)`)
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- DONE split out
|
- DONE split out
|
||||||
@ -175,7 +175,7 @@ var setup = function(){
|
|||||||
- DONE Format parser/generator
|
- DONE Format parser/generator
|
||||||
collapsed:: true
|
collapsed:: true
|
||||||
- DONE split out
|
- DONE split out
|
||||||
- DONE define api (see: `<editor>.__code2text__(..) / <editor>.__text2code__(..)`)
|
- DONE define api (see: `<editor>.__code2text__(..) / <editor>.__text2code__(..)`)
|
||||||
- CSS
|
- CSS
|
||||||
- separate out settings
|
- separate out settings
|
||||||
- separate out theming
|
- separate out theming
|
||||||
@ -245,21 +245,20 @@ var setup = function(){
|
|||||||
- y
|
- y
|
||||||
- z
|
- z
|
||||||
- c
|
- c
|
||||||
- > quote
|
- > quote
|
||||||
id::quote-example
|
|
||||||
- Notes
|
- Notes
|
||||||
- NOTE: a note text
|
- NOTE: a note text
|
||||||
- NOTE:
|
- NOTE:
|
||||||
- a root note can also be empty
|
- a root note can also be empty
|
||||||
- click on the outer border to edit root
|
- click on the outer border to edit root
|
||||||
- // C-style comment
|
- // C-style comment
|
||||||
- ; ASM-style comment
|
- ; ASM-style comment
|
||||||
- XXX Highlight
|
- XXX Highlight
|
||||||
- DONE Done (toggled via: `ctrl-d`)
|
- DONE Done (toggled via: `ctrl-d`)
|
||||||
- Basic inline *bold*, _italic_ and ~striked~
|
- Basic inline *bold*, _italic_ and ~striked~
|
||||||
- Marking ==text==
|
- Marking ==text==
|
||||||
- Code:
|
- Code:
|
||||||
- Inline quoting `html <b>code</b>`
|
- Inline quoting `html <b>code</b>`
|
||||||
- code blocks
|
- code blocks
|
||||||
```javascript
|
```javascript
|
||||||
var text = 'Hello, world!'
|
var text = 'Hello, world!'
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user