Skip to content

Commit

Permalink
Fix text editing tool when text object is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
edemaine committed Jan 27, 2024
1 parent c0906eb commit d9412f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ To see every change with descriptions aimed at developers, see
As a continuously updated web app, Cocreate uses dates
instead of version numbers.

## 2024-01-27

* Fix text editing tool when text object is deleted (by user or someone else)

## 2023-12-14

* Improve SVG export font embedding
Expand Down
2 changes: 0 additions & 2 deletions client/RenderObjects.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,6 @@ export class RenderObjects
svgG.remove() while (svgG = g.lastChild) != text
@texDelete id if @texById[id]?
content = obj.text
input = document.getElementById 'textInput'
## Extract $math$ and $$display math$$ expressions.
## Based loosely on Coauthor's `replaceMathBlocks`.
readyJobs = []
Expand Down Expand Up @@ -619,7 +618,6 @@ export class RenderObjects
delete @dom[id]
delete @bbox[id]
#@dbvt.remove id
tools.text.stop() if id == pointers.text
@texDelete id if @texById[id]?
@updated id
@renderAnchors id if @anchors?[id]?
Expand Down
10 changes: 5 additions & 5 deletions client/tools/modes.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -780,12 +780,13 @@ defineTool
pointers.highlight = new Highlighter currentBoard(), 'text'
pointers.undoable = null
pointers.text = null
currentBoard().onRemove = (id) =>
@resetInput()
mainBoard.selection.onRemove = (id) =>
if pointers.text == id # someone deleted text object while selected
@stop()
@start()
stop: ->
delete currentBoard().onRemove
delete mainBoard.selection.onRemove
pointers.cursor?.remove()
pointers.cursor = null
return unless (id = pointers.text)?
Expand All @@ -797,8 +798,8 @@ defineTool
pointers.text = null
up: (e) ->
return unless e.type == 'pointerup' # ignore pointerleave
## Stop editing any previous text object.
tools.text.stop()
## Stop editing any previous text object, by clearing selection
## which calls onRemove handler and resets mode.
mainBoard.selection.clear()
## In future, may support dragging a rectangular container for text,
## but maybe only after SVG 2's <text> flow support...
Expand Down Expand Up @@ -840,7 +841,6 @@ defineTool
return if pointers.text == ids[0]
obj = Objects.findOne ids[0]
return unless obj?.type == 'text'
tools.text.stop()
mainBoard.selection.clear()
pointers.text = obj._id
mainBoard.selection.addId pointers.text
Expand Down

0 comments on commit d9412f3

Please sign in to comment.