feat: add getRange api #429

This commit is contained in:
Hufe921
2024-01-31 21:40:04 +08:00
parent 7ab103edd9
commit 2a6a41c8c9
4 changed files with 26 additions and 0 deletions
+10
View File
@@ -57,6 +57,16 @@ Usage:
const wordCount = await instance.command.getWordCount() const wordCount = await instance.command.getWordCount()
``` ```
## getRange
Feature: Get range
Usage:
```javascript
const range = instance.command.getRange()
```
## getRangeText ## getRangeText
Feature: Get range text Feature: Get range text
+10
View File
@@ -57,6 +57,16 @@ const editorOption = await instance.command.getOptions()
const wordCount = await instance.command.getWordCount() const wordCount = await instance.command.getWordCount()
``` ```
## getRange
功能:获取选区
用法:
```javascript
const range = instance.command.getRange()
```
## getRangeText ## getRangeText
功能:获取选区文本 功能:获取选区文本
+2
View File
@@ -97,6 +97,7 @@ export class Command {
public getHTML: CommandAdapt['getHTML'] public getHTML: CommandAdapt['getHTML']
public getText: CommandAdapt['getText'] public getText: CommandAdapt['getText']
public getWordCount: CommandAdapt['getWordCount'] public getWordCount: CommandAdapt['getWordCount']
public getRange: CommandAdapt['getRange']
public getRangeText: CommandAdapt['getRangeText'] public getRangeText: CommandAdapt['getRangeText']
public getRangeContext: CommandAdapt['getRangeContext'] public getRangeContext: CommandAdapt['getRangeContext']
public getRangeRow: CommandAdapt['getRangeRow'] public getRangeRow: CommandAdapt['getRangeRow']
@@ -209,6 +210,7 @@ export class Command {
this.getHTML = adapt.getHTML.bind(adapt) this.getHTML = adapt.getHTML.bind(adapt)
this.getText = adapt.getText.bind(adapt) this.getText = adapt.getText.bind(adapt)
this.getWordCount = adapt.getWordCount.bind(adapt) this.getWordCount = adapt.getWordCount.bind(adapt)
this.getRange = adapt.getRange.bind(adapt)
this.getRangeText = adapt.getRangeText.bind(adapt) this.getRangeText = adapt.getRangeText.bind(adapt)
this.getRangeContext = adapt.getRangeContext.bind(adapt) this.getRangeContext = adapt.getRangeContext.bind(adapt)
this.getRangeRow = adapt.getRangeRow.bind(adapt) this.getRangeRow = adapt.getRangeRow.bind(adapt)
+4
View File
@@ -1961,6 +1961,10 @@ export class CommandAdapt {
return this.workerManager.getWordCount() return this.workerManager.getWordCount()
} }
public getRange(): IRange {
return deepClone(this.range.getRange())
}
public getRangeText(): string { public getRangeText(): string {
return this.range.toString() return this.range.toString()
} }