Skip to content

Commit

Permalink
bugfix and cleanup...
Browse files Browse the repository at this point in the history
Signed-off-by: Alex A. Naanou <[email protected]>
  • Loading branch information
flynx committed Nov 26, 2023
1 parent 0524c26 commit 91ed572
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 52 deletions.
33 changes: 15 additions & 18 deletions experiments/outline-editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ var quoted = {
quote: function(_, code){
return `<code>${ this.encode(code) }</code>` },

pre_pattern: /(?<!\\)```(.*\s*\n)((\n|.)*?)\h*(?<!\\)```[ \t]*(?:$|\n)/g,
pre_pattern: /(?<!\\)```(.*\s*\n)((\n|.)*?)\h*(?<!\\)```[ \t]*(?:$|\n)/gm,
preEncode: function(text){
return this.encode(text)
.replace(/`/, '\\`') },
Expand Down Expand Up @@ -912,7 +912,7 @@ var JSONOutline = {
code.replace(/\x00/g, ''))
// split text into parsable and non-parsable sections...
var sections = text
// split fomat:
// split format:
// [ text <match> <type> <body>, ... ]
.split(/(<(pre|code)(?:|\s[^>]*)>((?:\n|.)*)<\/\2>)/g)
// sort out the sections...
Expand All @@ -934,14 +934,11 @@ var JSONOutline = {
.join('')
// stage: post...
elem.text = run('post', text)


// patch for showing trailing empty lines in dom...
elem.text =
// XXX POST_PRE_WHITESPACE adding a </pre> exception here feels hacky...
// ...a space after pre will force a new line but not
// adding it will hide a single empty line after...
(elem.text == ''
|| elem.text.endsWith('</pre>')) ?
// XXX adding a </pre> exception here feels hacky...
|| elem.text.trim().endsWith('</pre>')) ?
elem.text
// NOTE: adding a space here is done to prevent the browser
// from hiding the last newline...
Expand Down Expand Up @@ -1930,16 +1927,16 @@ var Outline = {
.clear()
.outline
.append(...level(data))
// update sizes of all the textareas (transparent)...
// NOTE: this is needed to make initial clicking into multi-line
// blocks place the cursor into the clicked location.
// ...this is done by expanding the textarea to the element
// size and enabling it to intercept clicks correctly...
setTimeout(function(){
var f = that._updateCodeSize
//var f = that._syncTextSize.bind(that)
for(var e of [...that.outline.querySelectorAll('textarea')]){
f(e) } }, 0)
//// update sizes of all the textareas (transparent)...
//// NOTE: this is needed to make initial clicking into multi-line
//// blocks place the cursor into the clicked location.
//// ...this is done by expanding the textarea to the element
//// size and enabling it to intercept clicks correctly...
//setTimeout(function(){
// var f = that._updateCodeSize
// //var f = that._syncTextSize.bind(that)
// for(var e of [...that.outline.querySelectorAll('textarea')]){
// f(e) } }, 0)
return this },
/*/ // XXX JSON version...
load: function(data){
Expand Down
34 changes: 0 additions & 34 deletions experiments/outline-editor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,40 +48,6 @@
-
- ## Bugs:
focused:: true
- BUG whitespace after trailing code block is not shown (see next bug for details)
- also see: `POST_PRE_WHITESPACE`
- DONE BUG horizontal whitespace after a block of code create an empty line after the `<pre>` tag...
collapsed:: true
- ```
code block -- resized on block edit (`keydown` in edit mode)
```
- this is due to `.update(..)` adding a `' '` to the text...
- DONE BUG leading/trailing blank lines mishandled:
collapsed:: true
- block sizing
- issues:
-
blank lines above and below -- the trailing blank is not initially shown

- the main reason for this is that we are not adding a `" "` after each generated block as we do on `.update(..)` -- move this functionality up...
- blank line at end of block is initially not shown
- this block contains two lines (empty below)

- ```
editor.Block(
editor.data(
editor.get()))
.querySelector('.view').innerHTML // formatting is OK...
```
- _...this is a resize issue (???)_
- running `.updateSize() and then `._updateViewSize(..)` does not fix the issue...
- simply replacing `._updateCodeSize(..)` with `._syncTextSize(..)` fixes this but breaks lots more stuff...
_...need a better sync mechanism, preferably CSS_
-
this block also contains two lines (empty above)
-
this block contains three lines (empty above and below)

- BUG: styling error...
- this _seems `to` work_
- `while` _this `does` not_
Expand Down

0 comments on commit 91ed572

Please sign in to comment.