Skip to content

Commit

Permalink
Make block gap widgets editable
Browse files Browse the repository at this point in the history
To work around poor iOS behavior on select-all.

Issue codemirror/dev#1304
  • Loading branch information
marijnh committed Dec 14, 2023
1 parent fdb12c0 commit 7cb7d5b
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/blockview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export class BlockWidgetView extends ContentView implements BlockView {
if (this.dom && this.prevWidget) this.prevWidget.destroy(this.dom)
this.prevWidget = null
this.setDOM(this.widget.toDOM(view))
this.dom!.contentEditable = "false"
if (!this.widget.editable) this.dom!.contentEditable = "false"
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/decoration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ export abstract class WidgetType {
/// @internal
get isHidden() { return false }

/// @internal
get editable() { return false }

/// This is called when the an instance of the widget is removed
/// from the editor view.
destroy(dom: HTMLElement) {}
Expand Down
2 changes: 2 additions & 0 deletions src/docview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,8 @@ class BlockGapWidget extends WidgetType {
return true
}

get editable() { return true }

get estimatedHeight() { return this.height }
}

Expand Down
2 changes: 1 addition & 1 deletion src/inlineview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export class WidgetView extends ContentView {
if (this.dom && this.prevWidget) this.prevWidget.destroy(this.dom)
this.prevWidget = null
this.setDOM(this.widget.toDOM(view))
this.dom!.contentEditable = "false"
if (!this.widget.editable) this.dom!.contentEditable = "false"
}
}

Expand Down

0 comments on commit 7cb7d5b

Please sign in to comment.