Skip to content

Commit

Permalink
release(logcat): v0.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
surunzi committed Oct 31, 2024
1 parent 877ece5 commit d0bba62
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 3 deletions.
2 changes: 1 addition & 1 deletion index.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
},
"logcat": {
"react": true,
"version": "0.3.4",
"version": "0.4.0",
"style": true,
"icon": false,
"test": true,
Expand Down
8 changes: 8 additions & 0 deletions src/logcat/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ Append entry.

Clear all entries.

### getSelection(): string

Get selected text.

### hasSelection(): boolean

Check if there is any selection.

### scrollToEnd(): void

Scroll to end.
Expand Down
22 changes: 21 additions & 1 deletion src/logcat/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ export default class Logcat extends Component<IOptions> {
this.isAtBottom = true
}
}
/** Check if there is any selection. */
hasSelection() {
const selection = window.getSelection()
if (selection && selection.anchorNode) {
if (this.container.contains(selection.anchorNode)) {
return true
}
}
return false
}
/** Get selected text. */
getSelection() {
if (!this.hasSelection()) {
return ''
}
const selection = window.getSelection()
return selection ? selection.toString() : ''
}
private _append = () => {
const isAtBottom = this.isAtBottom
this.container.appendChild(this.frag)
Expand Down Expand Up @@ -249,7 +267,9 @@ export default class Logcat extends Component<IOptions> {
}
})

this.$container.on('scroll', this.onScroll)
this.$container
.on('scroll', this.onScroll)
.on('click', () => (this.isAtBottom = false))
}
private onScroll = () => {
const { scrollHeight, clientHeight, scrollTop } = this
Expand Down
2 changes: 1 addition & 1 deletion src/logcat/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "logcat",
"version": "0.3.4",
"version": "0.4.0",
"description": "Android logcat viewer",
"luna": {
"react": true
Expand Down

0 comments on commit d0bba62

Please sign in to comment.