Skip to content
This repository has been archived by the owner on Aug 18, 2019. It is now read-only.

Commit

Permalink
Notes on status
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Jun 10, 2011
1 parent b097cf8 commit 23570fd
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ HTML5 Edit is contenteditable for all.

HTML5 Edit is currently in the research phase. It is currently a research project aimed at finding new ways of doing things. In HTML5 Edit's case, allowing anyone to use contenteditable.

To see it's current technical status see STATUS.md


## Learning
Expand Down
21 changes: 21 additions & 0 deletions STATUS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# The Status of HTML5 Edit

## Working

- slices are working without splitting an element
- basic cleans are working
- reading and applying selections are working


## Not Working

- `.apply()` and `.clean()` work, however they cause the cursor to loose it's position if the cursor is in a series of empty elements - this is due to the htmlIndex to textIndex to htmlIndex conversion, which is lossy. The fix for this could be using `diff_match_patch` instead of this conversion
- **why is this?** this happens because `a<p></p><p>|</p><p></p>b` has the same textIndex as `a<p></p><p>|</p><p></p>|b` - the latter is what is applied
- `.slice(start,finish)` is working, although it will not split an element as that is quite complicated


## Next Steps

- see if `diff_match_patch` implementation works (solves the selection issues)
- if that doesn't work, then I will have to think very hard
- for `.apply()` I can always do: `.select()` afterwards, but for `.clean()` that will require something advance OR a token insert
10 changes: 7 additions & 3 deletions src/core/selection.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ $.fn.htmlSelectionRange = (selectionRange) ->
# Check heirarchy
try
# Level start offset
debugger
#debugger
if true
$start = $(range.startContainer).element()
startOffset = $start.text().indexOf($(range.startContainer).text())
Expand Down Expand Up @@ -334,12 +334,16 @@ $.fn.htmlSelection = (selectionRange) ->
$slice

# Select the current element
$.fn.select = ->
$.fn.select = (all) ->
# Prepare
$el = $(this)
all or= false

# Select
$el.htmlSelectionRange({selectionStart:0,selectionEnd:0})
$el.htmlSelectionRange(
selectionStart: 0
selectionEnd: if all then $el.rawHtml().length else 0
)
$el.focus()

# Return
Expand Down
4 changes: 2 additions & 2 deletions src/core/slice.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -148,13 +148,13 @@ String.prototype.levelHtmlIndexes = (start, finish) ->

# Apply the changes to a slice
$.fn.apply = ->
$slice = $(this)
$slice = $(this).addClass('apply')
$originalOld = $slice.data('slice-parent-old')
$originalNew = $slice.data('slice-parent-new')
if !$originalOld or !$originalNew
return $slice
$originalOld.html($originalNew.html())
# needs cursor updating
#$originalOld.find('.apply').removeClass('apply').select(true)

$.fn.textSlice = (start,finish) ->
[startIndex,finishIndex] = html.levelTextIndexes(start,finish)
Expand Down

0 comments on commit 23570fd

Please sign in to comment.