feat: location catalog api
This commit is contained in:
@@ -87,6 +87,7 @@ export class Command {
|
||||
private static removeControl: CommandAdapt['removeControl']
|
||||
private static setLocale: CommandAdapt['setLocale']
|
||||
private static getCatalog: CommandAdapt['getCatalog']
|
||||
private static locationCatalog: CommandAdapt['locationCatalog']
|
||||
|
||||
constructor(adapt: CommandAdapt) {
|
||||
Command.mode = adapt.mode.bind(adapt)
|
||||
@@ -166,6 +167,7 @@ export class Command {
|
||||
Command.removeControl = adapt.removeControl.bind(adapt)
|
||||
Command.setLocale = adapt.setLocale.bind(adapt)
|
||||
Command.getCatalog = adapt.getCatalog.bind(adapt)
|
||||
Command.locationCatalog = adapt.locationCatalog.bind(adapt)
|
||||
}
|
||||
|
||||
// 全局命令
|
||||
@@ -483,4 +485,8 @@ export class Command {
|
||||
return Command.getCatalog()
|
||||
}
|
||||
|
||||
public executeLocationCatalog(titleId: string) {
|
||||
return Command.locationCatalog(titleId)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1660,4 +1660,23 @@ export class CommandAdapt {
|
||||
return this.workerManager.getCatalog()
|
||||
}
|
||||
|
||||
public locationCatalog(titleId: string) {
|
||||
const elementList = this.draw.getMainElementList()
|
||||
let newIndex = -1
|
||||
for (let e = 0; e < elementList.length; e++) {
|
||||
const element = elementList[e]
|
||||
if (element.titleId === titleId && elementList[e + 1]?.titleId !== titleId) {
|
||||
newIndex = e
|
||||
break
|
||||
}
|
||||
}
|
||||
if (!~newIndex) return
|
||||
this.range.setRange(newIndex, newIndex)
|
||||
this.draw.render({
|
||||
curIndex: newIndex,
|
||||
isCompute: false,
|
||||
isSubmitHistory: false
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user